| 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..b396f26d32fd0f7bcab2bf761a0c084f63607b6c 100644
|
| --- a/Source/core/html/canvas/WebGLRenderingContextBase.cpp
|
| +++ b/Source/core/html/canvas/WebGLRenderingContextBase.cpp
|
| @@ -727,6 +727,9 @@ void WebGLRenderingContextBase::initializeNewContext()
|
|
|
| m_backDrawBuffer = GL_BACK;
|
|
|
| + // set the default read color buffer for FBO
|
| + m_readbufferOfFBO = GL_COLOR_ATTACHMENT0;
|
| +
|
| if (isWebGL2OrHigher()) {
|
| m_defaultVertexArrayObject = WebGLVertexArrayObject::create(this, WebGLVertexArrayObjectBase::VaoTypeDefault);
|
| } else {
|
| @@ -1543,6 +1546,18 @@ bool WebGLRenderingContextBase::validateSettableTexFormat(const char* functionNa
|
| return true;
|
| }
|
|
|
| +bool WebGLRenderingContextBase::validateReadBufferAttachment(const char* functionName, const WebGLFramebuffer* readFramebufferBinding)
|
| +{
|
| + if (readFramebufferBinding) {
|
| + WebGLSharedObject* attachmentObject = readFramebufferBinding->getAttachmentObject(m_readbufferOfFBO);
|
| + if (!attachmentObject) {
|
| + synthesizeGLError(GL_INVALID_OPERATION, functionName, "no image attached to read buffer");
|
| + return false;
|
| + }
|
| + }
|
| + 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 +1588,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 +1635,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 +3378,9 @@ void WebGLRenderingContextBase::readPixels(GLint x, GLint y, GLsizei width, GLsi
|
| return;
|
| }
|
|
|
| + if (!validateReadBufferAttachment("readPixels", readFramebufferBinding))
|
| + return;
|
| +
|
| clearIfComposited();
|
| void* data = pixels->baseAddress();
|
|
|
|
|