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 d1d1d9ce97e67a92688eff24a752e9cb06fd542a..4652c38b229ddf58da8775ee4f000c6e17c6b47f 100644 |
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc |
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc |
@@ -967,6 +967,7 @@ class GLES2DecoderImpl : public GLES2Decoder, |
void ProduceTextureRef(std::string func_name, TextureRef* texture_ref, |
GLenum target, const GLbyte* data); |
+ void EnsureTextureForClientId(GLuint client_id); |
void DoConsumeTextureCHROMIUM(GLenum target, const GLbyte* key); |
void DoCreateAndConsumeTextureCHROMIUM(GLenum target, const GLbyte* key, |
GLuint client_id); |
@@ -11679,6 +11680,19 @@ void GLES2DecoderImpl::DoConsumeTextureCHROMIUM(GLenum target, |
} |
} |
+void GLES2DecoderImpl::EnsureTextureForClientId(GLuint client_id) { |
+ TextureRef* texture_ref = GetTexture(client_id); |
+ if (!texture_ref) { |
+ GLuint service_id; |
+ glGenTextures(1, &service_id); |
+ DCHECK_NE(0u, service_id); |
+ CreateTexture(client_id, service_id); |
piman
2015/04/03 18:17:14
I think we also want to do the texture_manager()->
|
+ } |
+} |
+ |
+// If CreateAndConsumeTexture fails we still need to ensure that the client_id |
+// provided is associated with a service_id/TextureRef for consistency, even if |
+// the resulting texture is incomplete. |
error::Error GLES2DecoderImpl::HandleCreateAndConsumeTextureCHROMIUMImmediate( |
uint32_t immediate_data_size, |
const void* cmd_data) { |
@@ -11687,24 +11701,28 @@ error::Error GLES2DecoderImpl::HandleCreateAndConsumeTextureCHROMIUMImmediate( |
const gles2::cmds::CreateAndConsumeTextureCHROMIUMImmediate*>( |
cmd_data); |
GLenum target = static_cast<GLenum>(c.target); |
+ uint32_t client_id = c.client_id; |
uint32_t data_size; |
if (!ComputeDataSize(1, sizeof(GLbyte), 64, &data_size)) { |
+ EnsureTextureForClientId(client_id); |
piman
2015/04/03 18:17:14
I think it's ok to skip here. We're losing the con
|
return error::kOutOfBounds; |
} |
if (data_size > immediate_data_size) { |
+ EnsureTextureForClientId(client_id); |
piman
2015/04/03 18:17:15
Here too.
|
return error::kOutOfBounds; |
} |
const GLbyte* mailbox = |
GetImmediateDataAs<const GLbyte*>(c, data_size, immediate_data_size); |
if (!validators_->texture_bind_target.IsValid(target)) { |
+ EnsureTextureForClientId(client_id); |
piman
2015/04/03 18:17:14
Here too. Because we don't have a valid target, af
|
LOCAL_SET_GL_ERROR_INVALID_ENUM( |
"glCreateAndConsumeTextureCHROMIUM", target, "target"); |
return error::kNoError; |
} |
if (mailbox == NULL) { |
+ EnsureTextureForClientId(client_id); |
piman
2015/04/03 18:17:14
Here too.
|
return error::kOutOfBounds; |
} |
- uint32_t client_id = c.client_id; |
DoCreateAndConsumeTextureCHROMIUM(target, mailbox, client_id); |
return error::kNoError; |
} |
@@ -11721,6 +11739,8 @@ void GLES2DecoderImpl::DoCreateAndConsumeTextureCHROMIUM(GLenum target, |
TextureRef* texture_ref = GetTexture(client_id); |
if (texture_ref) { |
+ // No need to call EnsureTextureForClientId here, the client_id already has |
+ // an associated texture. |
LOCAL_SET_GL_ERROR( |
GL_INVALID_OPERATION, |
"glCreateAndConsumeTextureCHROMIUM", "client id already in use"); |
@@ -11728,12 +11748,15 @@ void GLES2DecoderImpl::DoCreateAndConsumeTextureCHROMIUM(GLenum target, |
} |
Texture* texture = group_->mailbox_manager()->ConsumeTexture(mailbox); |
if (!texture) { |
+ EnsureTextureForClientId(client_id); |
LOCAL_SET_GL_ERROR( |
GL_INVALID_OPERATION, |
"glCreateAndConsumeTextureCHROMIUM", "invalid mailbox name"); |
return; |
} |
+ |
if (texture->target() != target) { |
+ EnsureTextureForClientId(client_id); |
LOCAL_SET_GL_ERROR( |
GL_INVALID_OPERATION, |
"glCreateAndConsumeTextureCHROMIUM", "invalid target"); |