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

Side by Side Diff: Source/modules/webgl/WebGL2RenderingContextBase.cpp

Issue 1300573002: WebGL 2: add readPixels API to read pixels into pixel pack buffer (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: move the new readPixels to WebGL 2 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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 } else { 237 } else {
238 if (mode == GL_BACK) { 238 if (mode == GL_BACK) {
239 synthesizeGLError(GL_INVALID_OPERATION, "readBuffer", "invalid read buffer"); 239 synthesizeGLError(GL_INVALID_OPERATION, "readBuffer", "invalid read buffer");
240 return; 240 return;
241 } 241 }
242 readFramebufferBinding->readBuffer(mode); 242 readFramebufferBinding->readBuffer(mode);
243 } 243 }
244 webContext()->readBuffer(mode); 244 webContext()->readBuffer(mode);
245 } 245 }
246 246
247 void WebGL2RenderingContextBase::readPixels(GLint x, GLint y, GLsizei width, GLs izei height, GLenum format, GLenum type, DOMArrayBufferView* pixels)
248 {
249 if (isContextLost())
250 return;
251 if (m_boundPixelPackBuffer.get()) {
252 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "PIXEL_PACK buffer should not bound");
253 return;
254 }
255
256 WebGLRenderingContextBase::readPixels(x, y, width, height, format, type, pix els);
257 }
258
259 void WebGL2RenderingContextBase::readPixels(GLint x, GLint y, GLsizei width, GLs izei height, GLenum format, GLenum type, long long offset)
260 {
261 if (isContextLost())
262 return;
263 if (!m_boundPixelPackBuffer.get()) {
264 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "no PIXEL_PACK buf fer bound");
265 return;
266 }
267
Zhenyao Mo 2015/08/18 21:48:39 There are some missing validations here. I think
yunchao 2015/08/19 09:33:39 Yeah, I have written the code to validate the buff
268 WebGLRenderingContextBase::readPixelsImpl(x, y, width, height, format, type, (void*)offset, 0);
Zhenyao Mo 2015/08/18 21:48:39 use static_cast instead of (void*).
yunchao 2015/08/19 09:33:39 Thanks! I tried static_cast, but it failed to buil
269 }
270
247 void WebGL2RenderingContextBase::renderbufferStorageImpl( 271 void WebGL2RenderingContextBase::renderbufferStorageImpl(
248 GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsize i height, 272 GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsize i height,
249 const char* functionName) 273 const char* functionName)
250 { 274 {
251 switch (internalformat) { 275 switch (internalformat) {
252 case GL_R8UI: 276 case GL_R8UI:
253 case GL_R8I: 277 case GL_R8I:
254 case GL_R16UI: 278 case GL_R16UI:
255 case GL_R16I: 279 case GL_R16I:
256 case GL_R32UI: 280 case GL_R32UI:
(...skipping 2186 matching lines...) Expand 10 before | Expand all | Expand 10 after
2443 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() 2467 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat()
2444 { 2468 {
2445 if (m_readFramebufferBinding && m_readFramebufferBinding->object()) 2469 if (m_readFramebufferBinding && m_readFramebufferBinding->object())
2446 return m_readFramebufferBinding->colorBufferFormat(); 2470 return m_readFramebufferBinding->colorBufferFormat();
2447 if (m_requestedAttributes.alpha()) 2471 if (m_requestedAttributes.alpha())
2448 return GL_RGBA; 2472 return GL_RGBA;
2449 return GL_RGB; 2473 return GL_RGB;
2450 } 2474 }
2451 2475
2452 } // namespace blink 2476 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698