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 "modules/webgl/WebGL2RenderingContextBase.h" | 6 #include "modules/webgl/WebGL2RenderingContextBase.h" |
7 | 7 |
8 #include "bindings/modules/v8/WebGLAny.h" | 8 #include "bindings/modules/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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 return; | 167 return; |
168 | 168 |
169 webContext()->invalidateSubFramebuffer(target, attachments.size(), attachmen ts.data(), x, y, width, height); | 169 webContext()->invalidateSubFramebuffer(target, attachments.size(), attachmen ts.data(), x, y, width, height); |
170 } | 170 } |
171 | 171 |
172 void WebGL2RenderingContextBase::readBuffer(GLenum mode) | 172 void WebGL2RenderingContextBase::readBuffer(GLenum mode) |
173 { | 173 { |
174 if (isContextLost()) | 174 if (isContextLost()) |
175 return; | 175 return; |
176 | 176 |
177 switch (mode) { | |
178 case GL_BACK: | |
179 case GL_NONE: | |
180 case GL_COLOR_ATTACHMENT0: | |
181 break; | |
182 default: | |
183 if (mode > GL_COLOR_ATTACHMENT0 | |
184 && mode < static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + maxColorAttachm ents())) | |
185 break; | |
186 synthesizeGLError(GL_INVALID_ENUM, "readBuffer", "invalid read buffer"); | |
187 return; | |
188 } | |
189 | |
190 WebGLFramebuffer* readFramebufferBinding = getFramebufferBinding(GL_READ_FRA MEBUFFER); | |
191 if (!readFramebufferBinding) { | |
192 ASSERT(drawingBuffer()); | |
193 if (mode != GL_BACK && mode != GL_NONE) { | |
194 synthesizeGLError(GL_INVALID_OPERATION, "readBuffer", "invalid read buffer"); | |
195 return; | |
196 } | |
197 m_readBufferOfDefaultFramebuffer = mode; | |
198 // translate GL_BACK to GL_COLOR_ATTACHMENT0, because the default | |
199 // framebuffer for WebGL is not fb 0, it is an internal fbo. | |
200 if (mode == GL_BACK) | |
201 mode = GL_COLOR_ATTACHMENT0; | |
202 } else { | |
203 if (mode == GL_BACK) { | |
204 synthesizeGLError(GL_INVALID_OPERATION, "readBuffer", "invalid read buffer"); | |
205 return; | |
206 } | |
207 readFramebufferBinding->readBuffer(mode); | |
208 } | |
177 webContext()->readBuffer(mode); | 209 webContext()->readBuffer(mode); |
178 } | 210 } |
179 | 211 |
180 void WebGL2RenderingContextBase::renderbufferStorageImpl( | 212 void WebGL2RenderingContextBase::renderbufferStorageImpl( |
181 GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsize i height, | 213 GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsize i height, |
182 const char* functionName) | 214 const char* functionName) |
183 { | 215 { |
184 switch (internalformat) { | 216 switch (internalformat) { |
185 case GL_R8UI: | 217 case GL_R8UI: |
186 case GL_R8I: | 218 case GL_R8I: |
(...skipping 1583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1770 return getIntParameter(scriptState, pname); | 1802 return getIntParameter(scriptState, pname); |
1771 case GL_PACK_SKIP_ROWS: | 1803 case GL_PACK_SKIP_ROWS: |
1772 return getIntParameter(scriptState, pname); | 1804 return getIntParameter(scriptState, pname); |
1773 case GL_PIXEL_PACK_BUFFER_BINDING: | 1805 case GL_PIXEL_PACK_BUFFER_BINDING: |
1774 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(m_bound PixelPackBuffer.get())); | 1806 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(m_bound PixelPackBuffer.get())); |
1775 case GL_PIXEL_UNPACK_BUFFER_BINDING: | 1807 case GL_PIXEL_UNPACK_BUFFER_BINDING: |
1776 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(m_bound PixelUnpackBuffer.get())); | 1808 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(m_bound PixelUnpackBuffer.get())); |
1777 case GL_RASTERIZER_DISCARD: | 1809 case GL_RASTERIZER_DISCARD: |
1778 return getBooleanParameter(scriptState, pname); | 1810 return getBooleanParameter(scriptState, pname); |
1779 case GL_READ_BUFFER: | 1811 case GL_READ_BUFFER: |
1780 return getUnsignedIntParameter(scriptState, pname); | 1812 { |
1813 GLint value = 0; | |
Zhenyao Mo
2015/07/07 17:20:31
nit: this should be GLenum to match.
yunchao
2015/07/08 06:43:52
Done.
| |
1814 if (!isContextLost()) { | |
1815 WebGLFramebuffer* readFramebufferBinding = getFramebufferBinding (GL_READ_FRAMEBUFFER); | |
1816 if (!readFramebufferBinding) | |
1817 value = m_readBufferOfDefaultFramebuffer; | |
1818 else | |
1819 value = readFramebufferBinding->getReadBuffer(); | |
1820 } | |
1821 return WebGLAny(scriptState, static_cast<unsigned>(value)); | |
1822 } | |
1781 case GL_READ_FRAMEBUFFER_BINDING: | 1823 case GL_READ_FRAMEBUFFER_BINDING: |
1782 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(m_readF ramebufferBinding.get())); | 1824 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(m_readF ramebufferBinding.get())); |
1783 case GL_SAMPLE_ALPHA_TO_COVERAGE: | 1825 case GL_SAMPLE_ALPHA_TO_COVERAGE: |
1784 return getBooleanParameter(scriptState, pname); | 1826 return getBooleanParameter(scriptState, pname); |
1785 case GL_SAMPLE_COVERAGE: | 1827 case GL_SAMPLE_COVERAGE: |
1786 return getBooleanParameter(scriptState, pname); | 1828 return getBooleanParameter(scriptState, pname); |
1787 // case GL_SAMPLER_BINDING WebGLSampler | 1829 // case GL_SAMPLER_BINDING WebGLSampler |
1788 case GL_TEXTURE_BINDING_2D_ARRAY: | 1830 case GL_TEXTURE_BINDING_2D_ARRAY: |
1789 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(m_textu reUnits[m_activeTextureUnit].m_texture2DArrayBinding.get())); | 1831 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(m_textu reUnits[m_activeTextureUnit].m_texture2DArrayBinding.get())); |
1790 case GL_TEXTURE_BINDING_3D: | 1832 case GL_TEXTURE_BINDING_3D: |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2224 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() | 2266 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() |
2225 { | 2267 { |
2226 if (m_readFramebufferBinding && m_readFramebufferBinding->object()) | 2268 if (m_readFramebufferBinding && m_readFramebufferBinding->object()) |
2227 return m_readFramebufferBinding->colorBufferFormat(); | 2269 return m_readFramebufferBinding->colorBufferFormat(); |
2228 if (m_requestedAttributes.alpha()) | 2270 if (m_requestedAttributes.alpha()) |
2229 return GL_RGBA; | 2271 return GL_RGBA; |
2230 return GL_RGB; | 2272 return GL_RGB; |
2231 } | 2273 } |
2232 | 2274 |
2233 } // namespace blink | 2275 } // namespace blink |
OLD | NEW |