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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 be 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 |
| 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; |
| 277 |
| 278 // If size is negative, or size is not large enough to store pixels, |
| 279 // those cases are handled by readPixelsImpl to generate INVALID_OPERATION. |
| 280 WebGLRenderingContextBase::readPixelsImpl(x, y, width, height, format, type,
reinterpret_cast<void*>(offset), size); |
| 281 } |
| 282 |
247 void WebGL2RenderingContextBase::renderbufferStorageImpl( | 283 void WebGL2RenderingContextBase::renderbufferStorageImpl( |
248 GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsize
i height, | 284 GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsize
i height, |
249 const char* functionName) | 285 const char* functionName) |
250 { | 286 { |
251 switch (internalformat) { | 287 switch (internalformat) { |
252 case GL_R8UI: | 288 case GL_R8UI: |
253 case GL_R8I: | 289 case GL_R8I: |
254 case GL_R16UI: | 290 case GL_R16UI: |
255 case GL_R16I: | 291 case GL_R16I: |
256 case GL_R32UI: | 292 case GL_R32UI: |
(...skipping 2214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2471 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() | 2507 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() |
2472 { | 2508 { |
2473 if (m_readFramebufferBinding && m_readFramebufferBinding->object()) | 2509 if (m_readFramebufferBinding && m_readFramebufferBinding->object()) |
2474 return m_readFramebufferBinding->colorBufferFormat(); | 2510 return m_readFramebufferBinding->colorBufferFormat(); |
2475 if (m_requestedAttributes.alpha()) | 2511 if (m_requestedAttributes.alpha()) |
2476 return GL_RGBA; | 2512 return GL_RGBA; |
2477 return GL_RGB; | 2513 return GL_RGB; |
2478 } | 2514 } |
2479 | 2515 |
2480 } // namespace blink | 2516 } // namespace blink |
OLD | NEW |