| Index: third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp
|
| diff --git a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp
|
| index 3d04ecf6f55805db757caba6b23430516db667ad..86e4aca91babbe766f93a29f05e25a3ba7189ee2 100644
|
| --- a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp
|
| +++ b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp
|
| @@ -371,20 +371,93 @@ ScriptValue WebGL2RenderingContextBase::getInternalformatParameter(ScriptState*
|
| }
|
| }
|
|
|
| -void WebGL2RenderingContextBase::invalidateFramebuffer(GLenum target, Vector<GLenum>& attachments)
|
| +bool WebGL2RenderingContextBase::checkAndTranslateAttachments(const char* functionName, GLenum target, const Vector<GLenum>& attachments, Vector<GLenum>& translatedAttachments)
|
| +{
|
| + GLsizei size = attachments.size();
|
| + translatedAttachments.resize(size);
|
| +
|
| + WebGLFramebuffer* framebufferBinding = getFramebufferBinding(target);
|
| + ASSERT(framebufferBinding || drawingBuffer());
|
| + if (!framebufferBinding) {
|
| + // For the default framebuffer
|
| + // Translate GL_COLOR/GL_DEPTH/GL_STENCIL, because the default framebuffer of WebGL is not fb 0, it is an internal fbo
|
| + for (GLsizei i = 0; i < size; ++i) {
|
| + switch (attachments[i]) {
|
| + case GL_COLOR:
|
| + translatedAttachments[i] = GL_COLOR_ATTACHMENT0;
|
| + break;
|
| + case GL_DEPTH:
|
| + translatedAttachments[i] = GL_DEPTH_ATTACHMENT;
|
| + break;
|
| + case GL_STENCIL:
|
| + translatedAttachments[i] = GL_STENCIL_ATTACHMENT;
|
| + break;
|
| + default:
|
| + synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid attachment");
|
| + return false;
|
| + }
|
| + }
|
| + } else {
|
| + // For the FBO
|
| + for (GLsizei i = 0; i < size; ++i) {
|
| + switch (attachments[i]) {
|
| + case GL_COLOR_ATTACHMENT0:
|
| + case GL_DEPTH_ATTACHMENT:
|
| + case GL_STENCIL_ATTACHMENT:
|
| + case GL_DEPTH_STENCIL_ATTACHMENT:
|
| + translatedAttachments[i] = attachments[i];
|
| + break;
|
| + default:
|
| + if (attachments[i] > GL_COLOR_ATTACHMENT0
|
| + && attachments[i] < static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + maxColorAttachments())) {
|
| + translatedAttachments[i] = attachments[i];
|
| + break;
|
| + }
|
| + synthesizeGLError(GL_INVALID_OPERATION, functionName, "invalid attachment");
|
| + return false;
|
| + }
|
| + }
|
| + }
|
| + return true;
|
| +}
|
| +
|
| +void WebGL2RenderingContextBase::invalidateFramebuffer(GLenum target, const Vector<GLenum>& attachments)
|
| {
|
| if (isContextLost())
|
| return;
|
|
|
| - webContext()->invalidateFramebuffer(target, attachments.size(), attachments.data());
|
| + if (!validateFramebufferTarget(target)) {
|
| + synthesizeGLError(GL_INVALID_ENUM, "invalidateFramebuffer", "invalid target");
|
| + return;
|
| + }
|
| +
|
| + Vector<GLenum> translatedAttachments;
|
| + if (!checkAndTranslateAttachments("invalidateFramebuffer", target, attachments, translatedAttachments))
|
| + return;
|
| +
|
| + webContext()->invalidateFramebuffer(target, translatedAttachments.size(), translatedAttachments.data());
|
| }
|
|
|
| -void WebGL2RenderingContextBase::invalidateSubFramebuffer(GLenum target, Vector<GLenum>& attachments, GLint x, GLint y, GLsizei width, GLsizei height)
|
| +void WebGL2RenderingContextBase::invalidateSubFramebuffer(GLenum target, const Vector<GLenum>& attachments, GLint x, GLint y, GLsizei width, GLsizei height)
|
| {
|
| if (isContextLost())
|
| return;
|
|
|
| - webContext()->invalidateSubFramebuffer(target, attachments.size(), attachments.data(), x, y, width, height);
|
| + if (!validateFramebufferTarget(target)) {
|
| + synthesizeGLError(GL_INVALID_ENUM, "invalidateFramebuffer", "invalid target");
|
| + return;
|
| + }
|
| +
|
| + if (width < 0 || height < 0) {
|
| + synthesizeGLError(GL_INVALID_VALUE, "invalidateSubFramebuffer", "invalid width or height");
|
| + return;
|
| + }
|
| +
|
| + Vector<GLenum> translatedAttachments;
|
| + if (!checkAndTranslateAttachments("invalidateSubFramebuffer", target, attachments, translatedAttachments))
|
| + return;
|
| +
|
| + webContext()->invalidateSubFramebuffer(target, translatedAttachments.size(), translatedAttachments.data(), x, y, width, height);
|
| }
|
|
|
| void WebGL2RenderingContextBase::readBuffer(GLenum mode)
|
|
|