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

Unified Diff: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp

Issue 2457363002: Add offset arguments to readPixels and compressedTex* per WebGL 2.0 spec. (Closed)
Patch Set: Rebased. Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698