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 793606f951a86dcf5642eb26107a2f41db725984..3b9593dbcab556e467f085199076226df2d97664 100644 |
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc |
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc |
@@ -935,7 +935,14 @@ class GLES2DecoderImpl : public GLES2Decoder, |
GLsizei height); |
void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key); |
+ void DoProduceTextureDirectCHROMIUM(GLuint texture, GLenum target, |
+ const GLbyte* key); |
+ void ProduceTextureRef(std::string func_name, TextureRef* texture_ref, |
+ GLenum target, const GLbyte* data); |
+ |
void DoConsumeTextureCHROMIUM(GLenum target, const GLbyte* key); |
+ void DoCreateAndConsumeTextureCHROMIUM(GLenum target, const GLbyte* key, |
+ GLuint client_id); |
void DoBindTexImage2DCHROMIUM( |
GLenum target, |
@@ -10183,25 +10190,44 @@ void GLES2DecoderImpl::DoProduceTextureCHROMIUM(GLenum target, |
"context", logger_.GetLogPrefix(), |
"mailbox[0]", static_cast<unsigned char>(data[0])); |
+ TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget( |
+ &state_, target); |
+ ProduceTextureRef("glProduceTextureCHROMIUM", texture_ref, target, data); |
+} |
+ |
+void GLES2DecoderImpl::DoProduceTextureDirectCHROMIUM(GLuint client_id, |
+ GLenum target, const GLbyte* data) { |
+ TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoProduceTextureDirectCHROMIUM", |
+ "context", logger_.GetLogPrefix(), |
+ "mailbox[0]", static_cast<unsigned char>(data[0])); |
+ |
+ ProduceTextureRef("glProduceTextureDirectCHROMIUM", GetTexture(client_id), |
+ target, data); |
+} |
+ |
+void GLES2DecoderImpl::ProduceTextureRef(std::string func_name, |
+ TextureRef* texture_ref, GLenum target, const GLbyte* data) { |
const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data); |
- DLOG_IF(ERROR, !mailbox.Verify()) << "ProduceTextureCHROMIUM was passed a " |
+ DLOG_IF(ERROR, !mailbox.Verify()) << func_name << " was passed a " |
"mailbox that was not generated by " |
"GenMailboxCHROMIUM."; |
- TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget( |
- &state_, target); |
if (!texture_ref) { |
LOCAL_SET_GL_ERROR( |
- GL_INVALID_OPERATION, |
- "glProduceTextureCHROMIUM", "unknown texture for target"); |
+ GL_INVALID_OPERATION, func_name.c_str(), "unknown texture for target"); |
return; |
} |
Texture* produced = texture_manager()->Produce(texture_ref); |
if (!produced) { |
LOCAL_SET_GL_ERROR( |
- GL_INVALID_OPERATION, |
- "glProduceTextureCHROMIUM", "invalid texture"); |
+ GL_INVALID_OPERATION, func_name.c_str(), "invalid texture"); |
+ return; |
+ } |
+ |
+ if (produced->target() != target) { |
Ken Russell (switch to Gerrit)
2014/06/02 22:46:54
Is this new code path tested?
Do any other side-e
bajones
2014/06/02 23:31:23
Informally. I'll add a unit test in the next CL re
|
+ LOCAL_SET_GL_ERROR( |
+ GL_INVALID_OPERATION, func_name.c_str(), "invalid target"); |
return; |
} |
@@ -10272,6 +10298,66 @@ void GLES2DecoderImpl::DoConsumeTextureCHROMIUM(GLenum target, |
} |
} |
+error::Error GLES2DecoderImpl::HandleCreateAndConsumeTextureCHROMIUMImmediate( |
+ uint32_t immediate_data_size, |
+ const gles2::cmds::CreateAndConsumeTextureCHROMIUMImmediate& c) { |
+ GLenum target = static_cast<GLenum>(c.target); |
+ uint32_t data_size; |
+ if (!ComputeDataSize(1, sizeof(GLbyte), 64, &data_size)) { |
+ return error::kOutOfBounds; |
+ } |
+ if (data_size > immediate_data_size) { |
+ return error::kOutOfBounds; |
+ } |
+ const GLbyte* mailbox = |
+ GetImmediateDataAs<const GLbyte*>(c, data_size, immediate_data_size); |
+ if (!validators_->texture_bind_target.IsValid(target)) { |
+ LOCAL_SET_GL_ERROR_INVALID_ENUM( |
+ "glCreateAndConsumeTextureCHROMIUM", target, "target"); |
+ return error::kNoError; |
+ } |
+ if (mailbox == NULL) { |
+ return error::kOutOfBounds; |
+ } |
+ uint32_t client_id = c.client_id; |
+ DoCreateAndConsumeTextureCHROMIUM(target, mailbox, client_id); |
+ return error::kNoError; |
+} |
+ |
+void GLES2DecoderImpl::DoCreateAndConsumeTextureCHROMIUM(GLenum target, |
+ const GLbyte* data, GLuint client_id) { |
+ TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoCreateAndConsumeTextureCHROMIUM", |
+ "context", logger_.GetLogPrefix(), |
+ "mailbox[0]", static_cast<unsigned char>(data[0])); |
+ const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data); |
+ DLOG_IF(ERROR, !mailbox.Verify()) << "CreateAndConsumeTextureCHROMIUM was " |
+ "passed a mailbox that was not " |
+ "generated by GenMailboxCHROMIUM."; |
+ |
+ TextureRef* texture_ref = GetTexture(client_id); |
+ if (texture_ref) { |
+ LOCAL_SET_GL_ERROR( |
+ GL_INVALID_OPERATION, |
+ "glCreateAndConsumeTextureCHROMIUM", "client id already in use"); |
+ return; |
+ } |
+ Texture* texture = group_->mailbox_manager()->ConsumeTexture(target, mailbox); |
+ if (!texture) { |
+ LOCAL_SET_GL_ERROR( |
+ GL_INVALID_OPERATION, |
+ "glCreateAndConsumeTextureCHROMIUM", "invalid mailbox name"); |
+ return; |
+ } |
+ if (texture->target() != target) { |
+ LOCAL_SET_GL_ERROR( |
+ GL_INVALID_OPERATION, |
+ "glCreateAndConsumeTextureCHROMIUM", "invalid target"); |
+ return; |
+ } |
+ |
+ texture_ref = texture_manager()->Consume(client_id, texture); |
+} |
+ |
void GLES2DecoderImpl::DoInsertEventMarkerEXT( |
GLsizei length, const GLchar* marker) { |
if (!marker) { |