Index: gpu/command_buffer/service/gles2_cmd_decoder.cc |
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc |
index dc07b30561674f26f2aad25170f654691a4e4ebb..def323b17e52ca80d47c2d2001d7fa155fcff7c5 100644 |
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc |
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc |
@@ -6160,23 +6160,70 @@ void GLES2DecoderImpl::DoFramebufferTextureLayer( |
void GLES2DecoderImpl::DoGetFramebufferAttachmentParameteriv( |
GLenum target, GLenum attachment, GLenum pname, GLint* params) { |
+ const char kFunctionName[] = "glGetFramebufferAttachmentParameteriv"; |
Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); |
if (!framebuffer) { |
- LOCAL_SET_GL_ERROR( |
- GL_INVALID_OPERATION, |
- "glGetFramebufferAttachmentParameteriv", "no framebuffer bound"); |
- return; |
+ if (!unsafe_es3_apis_enabled()) { |
+ LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, |
+ "no framebuffer bound"); |
+ return; |
+ } |
+ if (!validators_->backbuffer_attachment.IsValid(attachment)) { |
+ LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, |
+ "invalid attachment for backbuffer"); |
+ return; |
+ } |
+ if (GetBackbufferServiceId() != 0) { // Emulated backbuffer. |
+ switch (attachment) { |
+ case GL_BACK: |
+ attachment = GL_COLOR_ATTACHMENT0; |
+ break; |
+ case GL_DEPTH: |
+ attachment = GL_DEPTH_ATTACHMENT; |
+ break; |
+ case GL_STENCIL: |
+ attachment = GL_STENCIL_ATTACHMENT; |
+ break; |
+ default: |
+ NOTREACHED(); |
+ break; |
+ } |
+ switch (pname) { |
+ case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: |
+ *params = static_cast<GLint>(GL_FRAMEBUFFER_DEFAULT); |
+ return; |
+ case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: |
+ case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: |
+ case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: |
+ case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: |
+ case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: |
+ case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: |
+ case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: |
+ case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: |
+ // Delegate to underlying driver. |
+ break; |
+ default: |
+ LOCAL_SET_GL_ERROR(GL_INVALID_ENUM, kFunctionName, |
+ "invalid pname for backbuffer"); |
+ return; |
+ } |
+ } |
+ } |
+ if (pname == GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT && |
+ features().use_img_for_multisampled_render_to_texture) { |
+ pname = GL_TEXTURE_SAMPLES_IMG; |
} |
- if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME) { |
+ |
+ // We didn't perform a full error check before gl call. |
+ LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(kFunctionName); |
+ glGetFramebufferAttachmentParameterivEXT(target, attachment, pname, params); |
+ GLenum error = LOCAL_PEEK_GL_ERROR(kFunctionName); |
+ |
+ if (error == GL_NO_ERROR && pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME) { |
Zhenyao Mo
2015/09/04 23:38:11
This is where the change is.
piman
2015/09/05 00:12:03
For this pname, should we just always return the t
|
+ // We should return client ID, not service ID. |
const Framebuffer::Attachment* attachment_object = |
framebuffer->GetAttachment(attachment); |
*params = attachment_object ? attachment_object->object_name() : 0; |
- } else { |
- if (pname == GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT && |
- features().use_img_for_multisampled_render_to_texture) { |
- pname = GL_TEXTURE_SAMPLES_IMG; |
- } |
- glGetFramebufferAttachmentParameterivEXT(target, attachment, pname, params); |
} |
} |