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

Unified Diff: Source/core/html/canvas/WebGLRenderingContextBase.cpp

Issue 1205573003: WebGL 2: validate read buffer attachment when reading from FBO (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: addressed zmo@'s feedback: readbuffer is per framebuffer, not per rendering context Created 5 years, 6 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/core/html/canvas/WebGLRenderingContextBase.cpp
diff --git a/Source/core/html/canvas/WebGLRenderingContextBase.cpp b/Source/core/html/canvas/WebGLRenderingContextBase.cpp
index 66aca1a524d6d8ab7eacc656b8705ac81aeffb47..d98daa19d284afc00d0fa04d21121b39bbff92fb 100644
--- a/Source/core/html/canvas/WebGLRenderingContextBase.cpp
+++ b/Source/core/html/canvas/WebGLRenderingContextBase.cpp
@@ -1543,6 +1543,19 @@ bool WebGLRenderingContextBase::validateSettableTexFormat(const char* functionNa
return true;
}
+bool WebGLRenderingContextBase::validateReadBufferAttachment(const char* functionName, const WebGLFramebuffer* readFramebufferBinding)
+{
+ if (readFramebufferBinding) {
+ GLenum readBuffer = readFramebufferBinding->getReadBuffer();
+ WebGLSharedObject* attachmentObject = readFramebufferBinding->getAttachmentObject(readBuffer);
+ if (!attachmentObject) {
+ synthesizeGLError(GL_INVALID_OPERATION, functionName, "no image attached to read buffer");
+ return false;
+ }
+ }
+ return true;
Zhenyao Mo 2015/07/06 17:52:25 Shouldn't you also check here that the back buffer
Ken Russell (switch to Gerrit) 2015/07/06 21:19:13 Agree with Mo's observation, though if the underly
yunchao 2015/07/07 08:10:39 Done.
+}
+
void WebGLRenderingContextBase::copyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
{
if (isContextLost())
@@ -1573,6 +1586,8 @@ void WebGLRenderingContextBase::copyTexImage2D(GLenum target, GLint level, GLenu
synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "copyTexImage2D", reason);
return;
}
+ if (!validateReadBufferAttachment("copyTexImage2D", readFramebufferBinding))
+ return;
clearIfComposited();
ScopedDrawingBufferBinder binder(drawingBuffer(), readFramebufferBinding);
webContext()->copyTexImage2D(target, level, internalformat, x, y, width, height, border);
@@ -1618,6 +1633,8 @@ void WebGLRenderingContextBase::copyTexSubImage2D(GLenum target, GLint level, GL
synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "copyTexSubImage2D", reason);
return;
}
+ if (!validateReadBufferAttachment("copyTexSubImage2D", readFramebufferBinding))
+ return;
clearIfComposited();
ScopedDrawingBufferBinder binder(drawingBuffer(), readFramebufferBinding);
webContext()->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
@@ -3359,6 +3376,9 @@ void WebGLRenderingContextBase::readPixels(GLint x, GLint y, GLsizei width, GLsi
return;
}
+ if (!validateReadBufferAttachment("readPixels", readFramebufferBinding))
+ return;
+
clearIfComposited();
void* data = pixels->baseAddress();

Powered by Google App Engine
This is Rietveld 408576698