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 ae331e5a4a080d4cf275e8cb35d2caf30011a28a..b05028a1c15924c57ed1cf5e0b9cc015c29e4e6f 100644 |
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc |
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc |
@@ -1602,6 +1602,11 @@ class GLES2DecoderImpl : public GLES2Decoder, public ErrorStateClient { |
void DoUniformMatrix4fv( |
GLint fake_location, GLsizei count, GLboolean transpose, |
const GLfloat* value); |
+ void DoUniformMatrix4fvWithCustomMatrixCHROMIUM(GLint fake_location, |
+ GLsizei count, |
+ GLint custom_matrix_id, |
+ GLboolean transpose, |
+ const GLfloat* value); |
void DoUniformMatrix2x3fv( |
GLint fake_location, GLsizei count, GLboolean transpose, |
const GLfloat* value); |
@@ -7446,6 +7451,49 @@ void GLES2DecoderImpl::DoUniformMatrix4fv( |
glUniformMatrix4fv(real_location, count, transpose, value); |
} |
+void GLES2DecoderImpl::DoUniformMatrix4fvWithCustomMatrixCHROMIUM( |
+ GLint fake_location, |
+ GLsizei count, |
+ GLint custom_matrix_id, |
+ GLboolean transpose, |
+ const GLfloat* default_value) { |
+ // We override exactly one 4x4 matrix. Dropping this parameter doesn't seem |
+ // to work with the PUTn autogen. |
piman
2016/02/16 23:56:33
Use PUT instead of PUTn, and a static count in the
liberato (no reviews please)
2016/02/17 17:50:32
Done.
|
+ if (count != 1) |
+ return; |
+ |
+ float gl_matrix[16]; |
+ bool copied_matrix = false; |
+ |
+ if (custom_matrix_id == 12345) { // TODO(liberato): enum |
piman
2016/02/16 23:56:33
When adding the enum, make sure it is added to the
liberato (no reviews please)
2016/02/17 17:50:32
done, and checked that the validation is working.
|
+ // This refers to the bound external texture on the active unit. |
+ TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; |
+ if (TextureRef* texture_ref = unit.bound_texture_external_oes.get()) { |
+ if (gl::GLImage* image = texture_ref->texture()->GetLevelImage( |
piman
2016/02/16 23:56:33
I suggest raising errors (GL_INVALID_OPERATION) or
liberato (no reviews please)
2016/02/17 17:50:32
i was planning on making it identity once StreamTe
piman
2016/02/17 21:57:29
Right, but what I meant is, this is always called
liberato (no reviews please)
2016/02/19 18:39:55
sorry, forgot to do this earlier. done.
|
+ GL_TEXTURE_EXTERNAL_OES, 0)) { |
+ copied_matrix = image->GetCustomMatrix(custom_matrix_id, gl_matrix); |
+ } |
+ } |
+ } |
+ // If the matrix was unsupported, then supply the default. |
+ // TODO(liberato): remove |default_value| and replace with an identity matrix. |
+ // It is only present as a transitionary step until StreamTexture supplies |
+ // the matrix via GLImage. Once that happens, GLRenderer can quit sending |
+ // in a default. |
+ if (!copied_matrix) |
+ memcpy(gl_matrix, default_value, sizeof(gl_matrix)); |
+ |
+ GLenum type = 0; |
+ GLint real_location = -1; |
+ if (!PrepForSetUniformByLocation(fake_location, "glUniformMatrix4fv", |
+ Program::kUniformMatrix4f, &real_location, |
+ &type, &count)) { |
+ return; |
+ } |
+ |
+ glUniformMatrix4fv(real_location, count, transpose, gl_matrix); |
+} |
+ |
void GLES2DecoderImpl::DoUniformMatrix2x3fv( |
GLint fake_location, GLsizei count, GLboolean transpose, |
const GLfloat* value) { |
@@ -13384,14 +13432,22 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM( |
// before presenting. |
if (source_target == GL_TEXTURE_EXTERNAL_OES) { |
// TODO(hkuang): get the StreamTexture transform matrix in GPU process |
- // instead of using kIdentityMatrix crbug.com/226218. |
+ // instead of using kIdentityMatrix crbug.com/226218. AVDACodecImage does |
+ // this correctly, but others (e.g., stream_texture_android.cc) don't. |
+ GLfloat transform_matrix[16]; |
+ bool got_matrix = false; |
+ if (gl::GLImage* image = |
+ source_texture->GetLevelImage(GL_TEXTURE_EXTERNAL_OES, 0)) { |
+ got_matrix = image->GetCustomMatrix(12345 /* TODO(liberato): enum */, |
+ transform_matrix); |
+ } |
+ if (!got_matrix) |
+ memcpy(transform_matrix, kIdentityMatrix, sizeof(transform_matrix)); |
copy_texture_CHROMIUM_->DoCopyTextureWithTransform( |
- this, source_target, source_texture->service_id(), |
- dest_target, dest_texture->service_id(), source_width, source_height, |
- unpack_flip_y == GL_TRUE, |
- unpack_premultiply_alpha == GL_TRUE, |
- unpack_unmultiply_alpha == GL_TRUE, |
- kIdentityMatrix); |
+ this, source_target, source_texture->service_id(), dest_target, |
+ dest_texture->service_id(), source_width, source_height, |
+ unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE, |
+ unpack_unmultiply_alpha == GL_TRUE, transform_matrix); |
} else { |
copy_texture_CHROMIUM_->DoCopyTexture( |
this, source_target, source_texture->service_id(), |