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

Unified 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: addressed zmo@'s and kbr@'s feedback 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 side-by-side diff with in-line comments
Download patch
Index: Source/modules/webgl/WebGL2RenderingContextBase.cpp
diff --git a/Source/modules/webgl/WebGL2RenderingContextBase.cpp b/Source/modules/webgl/WebGL2RenderingContextBase.cpp
index 672270918c6d75a9ccdd2152dd3c76bb7ab830f9..dd74e171b0cd0713d7c26d000ad37b7a0c1b85f0 100644
--- a/Source/modules/webgl/WebGL2RenderingContextBase.cpp
+++ b/Source/modules/webgl/WebGL2RenderingContextBase.cpp
@@ -244,6 +244,42 @@ void WebGL2RenderingContextBase::readBuffer(GLenum mode)
webContext()->readBuffer(mode);
}
+void WebGL2RenderingContextBase::readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, DOMArrayBufferView* pixels)
+{
+ if (isContextLost())
+ return;
+ if (m_boundPixelPackBuffer.get()) {
+ synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "PIXEL_PACK buffer should not be bound");
+ return;
+ }
+
+ WebGLRenderingContextBase::readPixels(x, y, width, height, format, type, pixels);
+}
+
+void WebGL2RenderingContextBase::readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, long long offset)
+{
+ if (isContextLost())
+ return;
+
+ if (!validateValueFitNonNegInt32("readPixels", "offset", offset))
+ return;
+
+ WebGLBuffer* buffer = m_boundPixelPackBuffer.get();
+ if (!buffer) {
+ synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "no PIXEL_PACK buffer bound");
+ return;
+ }
+
+ // Need to validate whether the pixel pack buffer is mapped,
+ // if we decide to expose mapBufferRange() to web developers.
+
+ long long size = buffer->getSize() - offset;
+
+ // If size is negative, or size is not large enough to store pixels,
+ // those cases are handled by readPixelsImpl to generate INVALID_OPERATION.
+ WebGLRenderingContextBase::readPixelsImpl(x, y, width, height, format, type, reinterpret_cast<void*>(offset), size);
+}
+
void WebGL2RenderingContextBase::renderbufferStorageImpl(
GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height,
const char* functionName)

Powered by Google App Engine
This is Rietveld 408576698