Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: Source/core/html/canvas/WebGL2RenderingContextBase.cpp

Issue 1120953002: WebGL 2: add read/write framebuffer binding points to related APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: addressed kbr@'s feedback: remove an argument that is not used Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1550 matching lines...) Expand 10 before | Expand all | Expand 10 after
1561 m_readFramebufferBinding = buffer; 1561 m_readFramebufferBinding = buffer;
1562 break; 1562 break;
1563 default: 1563 default:
1564 synthesizeGLError(GL_INVALID_ENUM, "bindFramebuffer", "invalid target"); 1564 synthesizeGLError(GL_INVALID_ENUM, "bindFramebuffer", "invalid target");
1565 return; 1565 return;
1566 } 1566 }
1567 1567
1568 setFramebuffer(target, buffer); 1568 setFramebuffer(target, buffer);
1569 } 1569 }
1570 1570
1571 void WebGL2RenderingContextBase::deleteFramebuffer(WebGLFramebuffer* framebuffer )
1572 {
1573 if (!deleteObject(framebuffer))
1574 return;
1575 GLenum target = 0;
1576 if (framebuffer == m_framebufferBinding) {
1577 if (framebuffer == m_readFramebufferBinding) {
1578 target = GL_FRAMEBUFFER;
1579 m_framebufferBinding = nullptr;
1580 m_readFramebufferBinding = nullptr;
1581 } else {
1582 target = GL_DRAW_FRAMEBUFFER;
1583 m_framebufferBinding = nullptr;
1584 }
1585 } else if (framebuffer == m_readFramebufferBinding) {
1586 target = GL_READ_FRAMEBUFFER;
1587 m_readFramebufferBinding = nullptr;
1588 }
1589 if (target) {
1590 drawingBuffer()->setFramebufferBinding(target, 0);
1591 // Have to call drawingBuffer()->bind() here to bind back to internal fb o.
1592 drawingBuffer()->bind(target);
1593 }
1594 }
1595
1571 ScriptValue WebGL2RenderingContextBase::getParameter(ScriptState* scriptState, G Lenum pname) 1596 ScriptValue WebGL2RenderingContextBase::getParameter(ScriptState* scriptState, G Lenum pname)
1572 { 1597 {
1573 if (isContextLost()) 1598 if (isContextLost())
1574 return ScriptValue::createNull(scriptState); 1599 return ScriptValue::createNull(scriptState);
1575 switch (pname) { 1600 switch (pname) {
1576 case GL_SHADING_LANGUAGE_VERSION: 1601 case GL_SHADING_LANGUAGE_VERSION:
1577 return WebGLAny(scriptState, "WebGL GLSL ES 3.00 (" + String(webContext( )->getString(GL_SHADING_LANGUAGE_VERSION)) + ")"); 1602 return WebGLAny(scriptState, "WebGL GLSL ES 3.00 (" + String(webContext( )->getString(GL_SHADING_LANGUAGE_VERSION)) + ")");
1578 case GL_VERSION: 1603 case GL_VERSION:
1579 return WebGLAny(scriptState, "WebGL 2.0 (" + String(webContext()->getStr ing(GL_VERSION)) + ")"); 1604 return WebGLAny(scriptState, "WebGL 2.0 (" + String(webContext()->getStr ing(GL_VERSION)) + ")");
1580 1605
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
2084 if (m_boundPixelUnpackBuffer == buffer) 2109 if (m_boundPixelUnpackBuffer == buffer)
2085 m_boundPixelUnpackBuffer = nullptr; 2110 m_boundPixelUnpackBuffer = nullptr;
2086 if (m_boundTransformFeedbackBuffer == buffer) 2111 if (m_boundTransformFeedbackBuffer == buffer)
2087 m_boundTransformFeedbackBuffer = nullptr; 2112 m_boundTransformFeedbackBuffer = nullptr;
2088 if (m_boundUniformBuffer == buffer) 2113 if (m_boundUniformBuffer == buffer)
2089 m_boundUniformBuffer = nullptr; 2114 m_boundUniformBuffer = nullptr;
2090 2115
2091 WebGLRenderingContextBase::removeBoundBuffer(buffer); 2116 WebGLRenderingContextBase::removeBoundBuffer(buffer);
2092 } 2117 }
2093 2118
2119 void WebGL2RenderingContextBase::restoreCurrentFramebuffer()
2120 {
2121 bindFramebuffer(GL_DRAW_FRAMEBUFFER, m_framebufferBinding.get());
2122 bindFramebuffer(GL_READ_FRAMEBUFFER, m_readFramebufferBinding.get());
2123 }
2124
2125 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat()
2126 {
2127 if (m_readFramebufferBinding && m_readFramebufferBinding->object())
2128 return m_readFramebufferBinding->colorBufferFormat();
2129 if (m_requestedAttributes.alpha())
2130 return GL_RGBA;
2131 return GL_RGB;
2132 }
2133
2094 } // namespace blink 2134 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/html/canvas/WebGL2RenderingContextBase.h ('k') | Source/core/html/canvas/WebGLFramebuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698