Chromium Code Reviews| Index: Source/modules/webgl/WebGLRenderingContextBase.cpp |
| diff --git a/Source/modules/webgl/WebGLRenderingContextBase.cpp b/Source/modules/webgl/WebGLRenderingContextBase.cpp |
| index 7cc1c5ec5e8113ad051139a8219ec9f9de1fcde4..30ef88c2b25d993423de217aeb67c938b17ce34c 100644 |
| --- a/Source/modules/webgl/WebGLRenderingContextBase.cpp |
| +++ b/Source/modules/webgl/WebGLRenderingContextBase.cpp |
| @@ -727,6 +727,8 @@ void WebGLRenderingContextBase::initializeNewContext() |
| m_backDrawBuffer = GL_BACK; |
| + m_readBufferOfDefaultFramebuffer = GL_BACK; |
| + |
| if (isWebGL2OrHigher()) { |
| m_defaultVertexArrayObject = WebGLVertexArrayObject::create(this, WebGLVertexArrayObjectBase::VaoTypeDefault); |
| } else { |
| @@ -1543,6 +1545,23 @@ bool WebGLRenderingContextBase::validateSettableTexFormat(const char* functionNa |
| return true; |
| } |
| +bool WebGLRenderingContextBase::validateReadBufferAttachment(const char* functionName, const WebGLFramebuffer* readFramebufferBinding) |
| +{ |
| + if (readFramebufferBinding) { |
| + GLenum readBuffer = readFramebufferBinding->getReadBuffer(); |
| + if (readBuffer == GL_NONE) |
| + return false; |
| + WebGLSharedObject* attachmentObject = readFramebufferBinding->getAttachmentObject(readBuffer); |
| + if (!attachmentObject) { |
| + synthesizeGLError(GL_INVALID_OPERATION, functionName, "no image attached to read buffer"); |
| + return false; |
| + } |
| + } else if (m_readBufferOfDefaultFramebuffer == GL_NONE) { |
| + return false; |
|
Ken Russell (switch to Gerrit)
2015/07/07 18:21:26
This must synthesize an INVALID_OPERATION error pe
yunchao
2015/07/08 06:43:52
Done.
|
| + } |
| + return true; |
| +} |
| + |
| void WebGLRenderingContextBase::copyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) |
| { |
| if (isContextLost()) |
| @@ -1573,6 +1592,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 +1639,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 +3382,9 @@ void WebGLRenderingContextBase::readPixels(GLint x, GLint y, GLsizei width, GLsi |
| return; |
| } |
| + if (!validateReadBufferAttachment("readPixels", readFramebufferBinding)) |
| + return; |
| + |
| clearIfComposited(); |
| void* data = pixels->baseAddress(); |