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 2097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2108 default: | 2108 default: |
2109 synthesizeGLError(GL_INVALID_ENUM, "readPixels", "invalid format"); | 2109 synthesizeGLError(GL_INVALID_ENUM, "readPixels", "invalid format"); |
2110 return false; | 2110 return false; |
2111 } | 2111 } |
2112 | 2112 |
2113 switch (type) { | 2113 switch (type) { |
2114 case GL_UNSIGNED_BYTE: | 2114 case GL_UNSIGNED_BYTE: |
2115 case GL_BYTE: | 2115 case GL_BYTE: |
2116 case GL_HALF_FLOAT: | 2116 case GL_HALF_FLOAT: |
2117 case GL_FLOAT: | 2117 case GL_FLOAT: |
2118 case GL_UNSIGNED_SHORT: | |
2118 case GL_UNSIGNED_SHORT_5_6_5: | 2119 case GL_UNSIGNED_SHORT_5_6_5: |
2119 case GL_UNSIGNED_SHORT_4_4_4_4: | 2120 case GL_UNSIGNED_SHORT_4_4_4_4: |
2120 case GL_UNSIGNED_SHORT_5_5_5_1: | 2121 case GL_UNSIGNED_SHORT_5_5_5_1: |
2122 case GL_SHORT: | |
2121 case GL_UNSIGNED_INT: | 2123 case GL_UNSIGNED_INT: |
2122 case GL_UNSIGNED_INT_2_10_10_10_REV: | 2124 case GL_UNSIGNED_INT_2_10_10_10_REV: |
2123 case GL_UNSIGNED_INT_10F_11F_11F_REV: | 2125 case GL_UNSIGNED_INT_10F_11F_11F_REV: |
2124 case GL_UNSIGNED_INT_5_9_9_9_REV: | 2126 case GL_UNSIGNED_INT_5_9_9_9_REV: |
2125 case GL_INT: | 2127 case GL_INT: |
2126 break; | 2128 break; |
2127 default: | 2129 default: |
2128 synthesizeGLError(GL_INVALID_ENUM, "readPixels", "invalid type"); | 2130 synthesizeGLError(GL_INVALID_ENUM, "readPixels", "invalid type"); |
2129 return false; | 2131 return false; |
2130 } | 2132 } |
2131 | 2133 |
2132 return true; | 2134 return true; |
2133 } | 2135 } |
2134 | 2136 |
2137 DOMArrayBufferView::ViewType WebGL2RenderingContextBase::readPixelsExpectedArray BufferViewType(GLenum type) | |
2138 { | |
2139 DOMArrayBufferView::ViewType expectedViewType; | |
Zhenyao Mo
2015/08/14 16:07:42
nit: you don't need this expectedViewType. You ca
| |
2140 switch (type) { | |
2141 case GL_BYTE: | |
2142 expectedViewType = DOMArrayBufferView::TypeInt8; | |
2143 break; | |
2144 case GL_UNSIGNED_SHORT: | |
2145 expectedViewType = DOMArrayBufferView::TypeUint16; | |
2146 break; | |
2147 case GL_SHORT: | |
2148 expectedViewType = DOMArrayBufferView::TypeInt16; | |
2149 break; | |
2150 case GL_HALF_FLOAT: | |
2151 expectedViewType = DOMArrayBufferView::TypeUint16; | |
2152 break; | |
2153 case GL_UNSIGNED_INT: | |
2154 case GL_UNSIGNED_INT_2_10_10_10_REV: | |
2155 case GL_UNSIGNED_INT_10F_11F_11F_REV: | |
2156 case GL_UNSIGNED_INT_5_9_9_9_REV: | |
2157 expectedViewType = DOMArrayBufferView::TypeUint32; | |
2158 break; | |
2159 case GL_INT: | |
2160 expectedViewType = DOMArrayBufferView::TypeInt32; | |
2161 break; | |
2162 default: | |
2163 return WebGLRenderingContextBase::readPixelsExpectedArrayBufferViewType( type); | |
2164 } | |
2165 return expectedViewType; | |
2166 } | |
2167 | |
2135 WebGLFramebuffer* WebGL2RenderingContextBase::getFramebufferBinding(GLenum targe t) | 2168 WebGLFramebuffer* WebGL2RenderingContextBase::getFramebufferBinding(GLenum targe t) |
2136 { | 2169 { |
2137 if (target == GL_READ_FRAMEBUFFER) | 2170 if (target == GL_READ_FRAMEBUFFER) |
2138 return m_readFramebufferBinding.get(); | 2171 return m_readFramebufferBinding.get(); |
2139 return m_framebufferBinding.get(); | 2172 return m_framebufferBinding.get(); |
2140 } | 2173 } |
2141 | 2174 |
2142 bool WebGL2RenderingContextBase::validateGetFramebufferAttachmentParameterFunc(c onst char* functionName, GLenum target, GLenum attachment) | 2175 bool WebGL2RenderingContextBase::validateGetFramebufferAttachmentParameterFunc(c onst char* functionName, GLenum target, GLenum attachment) |
2143 { | 2176 { |
2144 if (!validateFramebufferTarget(target)) { | 2177 if (!validateFramebufferTarget(target)) { |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2418 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() | 2451 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() |
2419 { | 2452 { |
2420 if (m_readFramebufferBinding && m_readFramebufferBinding->object()) | 2453 if (m_readFramebufferBinding && m_readFramebufferBinding->object()) |
2421 return m_readFramebufferBinding->colorBufferFormat(); | 2454 return m_readFramebufferBinding->colorBufferFormat(); |
2422 if (m_requestedAttributes.alpha()) | 2455 if (m_requestedAttributes.alpha()) |
2423 return GL_RGBA; | 2456 return GL_RGBA; |
2424 return GL_RGB; | 2457 return GL_RGB; |
2425 } | 2458 } |
2426 | 2459 |
2427 } // namespace blink | 2460 } // namespace blink |
OLD | NEW |