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/modules/webgl/WebGL2RenderingContextBase.cpp

Issue 1288303002: WebGL 2: add types into glReadPixels (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: nits Created 5 years, 4 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 "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
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 switch (type) {
2140 case GL_BYTE:
2141 return DOMArrayBufferView::TypeInt8;
2142 case GL_UNSIGNED_SHORT:
2143 return DOMArrayBufferView::TypeUint16;
2144 case GL_SHORT:
2145 return DOMArrayBufferView::TypeInt16;
2146 case GL_HALF_FLOAT:
2147 return DOMArrayBufferView::TypeUint16;
2148 case GL_UNSIGNED_INT:
2149 case GL_UNSIGNED_INT_2_10_10_10_REV:
2150 case GL_UNSIGNED_INT_10F_11F_11F_REV:
2151 case GL_UNSIGNED_INT_5_9_9_9_REV:
2152 return DOMArrayBufferView::TypeUint32;
2153 case GL_INT:
2154 return DOMArrayBufferView::TypeInt32;
2155 default:
2156 return WebGLRenderingContextBase::readPixelsExpectedArrayBufferViewType( type);
2157 }
2158 }
2159
2135 WebGLFramebuffer* WebGL2RenderingContextBase::getFramebufferBinding(GLenum targe t) 2160 WebGLFramebuffer* WebGL2RenderingContextBase::getFramebufferBinding(GLenum targe t)
2136 { 2161 {
2137 if (target == GL_READ_FRAMEBUFFER) 2162 if (target == GL_READ_FRAMEBUFFER)
2138 return m_readFramebufferBinding.get(); 2163 return m_readFramebufferBinding.get();
2139 return m_framebufferBinding.get(); 2164 return m_framebufferBinding.get();
2140 } 2165 }
2141 2166
2142 bool WebGL2RenderingContextBase::validateGetFramebufferAttachmentParameterFunc(c onst char* functionName, GLenum target, GLenum attachment) 2167 bool WebGL2RenderingContextBase::validateGetFramebufferAttachmentParameterFunc(c onst char* functionName, GLenum target, GLenum attachment)
2143 { 2168 {
2144 if (!validateFramebufferTarget(target)) { 2169 if (!validateFramebufferTarget(target)) {
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
2418 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() 2443 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat()
2419 { 2444 {
2420 if (m_readFramebufferBinding && m_readFramebufferBinding->object()) 2445 if (m_readFramebufferBinding && m_readFramebufferBinding->object())
2421 return m_readFramebufferBinding->colorBufferFormat(); 2446 return m_readFramebufferBinding->colorBufferFormat();
2422 if (m_requestedAttributes.alpha()) 2447 if (m_requestedAttributes.alpha())
2423 return GL_RGBA; 2448 return GL_RGBA;
2424 return GL_RGB; 2449 return GL_RGB;
2425 } 2450 }
2426 2451
2427 } // namespace blink 2452 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/webgl/WebGL2RenderingContextBase.h ('k') | Source/modules/webgl/WebGLRenderingContextBase.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698