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 c2b08e722741834f3e8ec84954d9708f6e05b3a3..d5dc522cd90c4ffc3ed7dfa36d014684cc40fb36 100644 |
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc |
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc |
@@ -1185,6 +1185,10 @@ class GLES2DecoderImpl : public GLES2Decoder, |
// Generates GL error if not. |
bool CheckBoundFramebuffersValid(const char* func_name); |
+ // Check that the currently bound read framebuffer has a color image |
+ // attached. Generates GL error if not. |
+ bool CheckBoundReadFramebufferColorAttachment(const char* func_name); |
+ |
// Check if a framebuffer meets our requirements. |
bool CheckFramebufferValid( |
Framebuffer* framebuffer, |
@@ -3194,6 +3198,21 @@ bool GLES2DecoderImpl::CheckBoundFramebuffersValid(const char* func_name) { |
func_name); |
} |
+bool GLES2DecoderImpl::CheckBoundReadFramebufferColorAttachment( |
+ const char* func_name) { |
+ Framebuffer* framebuffer = features().chromium_framebuffer_multisample ? |
+ framebuffer_state_.bound_read_framebuffer.get() : |
+ framebuffer_state_.bound_draw_framebuffer.get(); |
+ if (!framebuffer) |
+ return true; |
+ if (framebuffer->GetAttachment(GL_COLOR_ATTACHMENT0) == NULL) { |
+ LOCAL_SET_GL_ERROR( |
+ GL_INVALID_OPERATION, func_name, "no color image attached"); |
+ return false; |
+ } |
+ return true; |
+} |
+ |
gfx::Size GLES2DecoderImpl::GetBoundReadFrameBufferSize() { |
Framebuffer* framebuffer = |
GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT); |
@@ -7436,6 +7455,10 @@ error::Error GLES2DecoderImpl::HandleReadPixels( |
return error::kNoError; |
} |
+ if (!CheckBoundReadFramebufferColorAttachment("glReadPixels")) { |
+ return error::kNoError; |
+ } |
+ |
if (!CheckBoundFramebuffersValid("glReadPixels")) { |
return error::kNoError; |
} |
@@ -8487,6 +8510,10 @@ void GLES2DecoderImpl::DoCopyTexImage2D( |
return; |
} |
+ if (!CheckBoundReadFramebufferColorAttachment("glCopyTexImage2D")) { |
+ return; |
+ } |
+ |
if (!CheckBoundFramebuffersValid("glCopyTexImage2D")) { |
return; |
} |
@@ -8597,6 +8624,10 @@ void GLES2DecoderImpl::DoCopyTexSubImage2D( |
return; |
} |
+ if (!CheckBoundReadFramebufferColorAttachment("glCopyTexSubImage2D")) { |
+ return; |
+ } |
+ |
if (!CheckBoundFramebuffersValid("glCopyTexSubImage2D")) { |
return; |
} |