Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Unified Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 379623002: Read framebuffer should have color image attached for ReadPixels/Copy{Sub}TexImage2D (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698