| Index: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
|
| diff --git a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
|
| index 2c6a745b0dc8a3204c97228059f648856baaf0ad..315e80768d1de323d0e2993d446b716e27601ea7 100644
|
| --- a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
|
| +++ b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
|
| @@ -4061,6 +4061,17 @@ void WebGLRenderingContextBase::readPixels(GLint x,
|
| GLenum format,
|
| GLenum type,
|
| DOMArrayBufferView* pixels) {
|
| + readPixelsHelper(x, y, width, height, format, type, pixels, 0);
|
| +}
|
| +
|
| +void WebGLRenderingContextBase::readPixelsHelper(GLint x,
|
| + GLint y,
|
| + GLsizei width,
|
| + GLsizei height,
|
| + GLenum format,
|
| + GLenum type,
|
| + DOMArrayBufferView* pixels,
|
| + GLuint offset) {
|
| if (isContextLost())
|
| return;
|
| // Due to WebGL's same-origin restrictions, it is not possible to
|
| @@ -4072,6 +4083,14 @@ void WebGLRenderingContextBase::readPixels(GLint x,
|
| "no destination ArrayBufferView");
|
| return;
|
| }
|
| + CheckedNumeric<GLuint> offsetInBytes = offset;
|
| + offsetInBytes *= pixels->typeSize();
|
| + if (!offsetInBytes.IsValid() ||
|
| + offsetInBytes.ValueOrDie() > pixels->byteLength()) {
|
| + synthesizeGLError(GL_INVALID_VALUE, "readPixels",
|
| + "destination offset out of range");
|
| + return;
|
| + }
|
| const char* reason = "framebuffer incomplete";
|
| WebGLFramebuffer* framebuffer = getReadFramebufferBinding();
|
| if (framebuffer &&
|
| @@ -4082,12 +4101,13 @@ void WebGLRenderingContextBase::readPixels(GLint x,
|
| }
|
| if (!validateReadPixelsFuncParameters(
|
| width, height, format, type, pixels,
|
| - static_cast<long long>(pixels->byteLength())))
|
| + static_cast<long long>(pixels->byteLength() -
|
| + offsetInBytes.ValueOrDie()))) {
|
| return;
|
| -
|
| + }
|
| clearIfComposited();
|
| - void* data = pixels->baseAddress();
|
| -
|
| + uint8_t* data =
|
| + static_cast<uint8_t*>(pixels->baseAddress()) + offsetInBytes.ValueOrDie();
|
| {
|
| ScopedDrawingBufferBinder binder(drawingBuffer(), framebuffer);
|
| contextGL()->ReadPixels(x, y, width, height, format, type, data);
|
|
|