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

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: offset should not be less than 0 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");
Ken Russell (switch to Gerrit) 2015/08/19 23:42:52 nit: "should not be bound"
yunchao 2015/08/20 08:16:38 Done.
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
264 if (!validateValueFitNonNegInt32("readPixels", "offset", offset))
265 return;
266
267 WebGLBuffer* buffer = m_boundPixelPackBuffer.get();
268 if (!buffer) {
269 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "no PIXEL_PACK buf fer bound");
270 return;
271 }
272
273 // Need to validate whether the pixel pack buffer is mapped,
274 // if we decide to expose mapBufferRange() to web developers.
275
276 long long size = buffer->getSize() - offset;
Zhenyao Mo 2015/08/19 17:20:23 nit: add a note if offset is larger than buffer si
yunchao 2015/08/20 08:16:38 Done.
277 WebGLRenderingContextBase::readPixelsImpl(x, y, width, height, format, type, reinterpret_cast<void*>(offset), size);
278 }
279
247 void WebGL2RenderingContextBase::renderbufferStorageImpl( 280 void WebGL2RenderingContextBase::renderbufferStorageImpl(
248 GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsize i height, 281 GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsize i height,
249 const char* functionName) 282 const char* functionName)
250 { 283 {
251 switch (internalformat) { 284 switch (internalformat) {
252 case GL_R8UI: 285 case GL_R8UI:
253 case GL_R8I: 286 case GL_R8I:
254 case GL_R16UI: 287 case GL_R16UI:
255 case GL_R16I: 288 case GL_R16I:
256 case GL_R32UI: 289 case GL_R32UI:
(...skipping 2214 matching lines...) Expand 10 before | Expand all | Expand 10 after
2471 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() 2504 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat()
2472 { 2505 {
2473 if (m_readFramebufferBinding && m_readFramebufferBinding->object()) 2506 if (m_readFramebufferBinding && m_readFramebufferBinding->object())
2474 return m_readFramebufferBinding->colorBufferFormat(); 2507 return m_readFramebufferBinding->colorBufferFormat();
2475 if (m_requestedAttributes.alpha()) 2508 if (m_requestedAttributes.alpha())
2476 return GL_RGBA; 2509 return GL_RGBA;
2477 return GL_RGB; 2510 return GL_RGB;
2478 } 2511 }
2479 2512
2480 } // namespace blink 2513 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698