Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 1584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1595 | 1595 |
| 1596 void DoUniformMatrix2fv( | 1596 void DoUniformMatrix2fv( |
| 1597 GLint fake_location, GLsizei count, GLboolean transpose, | 1597 GLint fake_location, GLsizei count, GLboolean transpose, |
| 1598 const GLfloat* value); | 1598 const GLfloat* value); |
| 1599 void DoUniformMatrix3fv( | 1599 void DoUniformMatrix3fv( |
| 1600 GLint fake_location, GLsizei count, GLboolean transpose, | 1600 GLint fake_location, GLsizei count, GLboolean transpose, |
| 1601 const GLfloat* value); | 1601 const GLfloat* value); |
| 1602 void DoUniformMatrix4fv( | 1602 void DoUniformMatrix4fv( |
| 1603 GLint fake_location, GLsizei count, GLboolean transpose, | 1603 GLint fake_location, GLsizei count, GLboolean transpose, |
| 1604 const GLfloat* value); | 1604 const GLfloat* value); |
| 1605 void DoUniformMatrix4fvWithCustomMatrixCHROMIUM(GLint fake_location, | |
| 1606 GLsizei count, | |
| 1607 GLint custom_matrix_id, | |
| 1608 GLboolean transpose, | |
| 1609 const GLfloat* value); | |
| 1605 void DoUniformMatrix2x3fv( | 1610 void DoUniformMatrix2x3fv( |
| 1606 GLint fake_location, GLsizei count, GLboolean transpose, | 1611 GLint fake_location, GLsizei count, GLboolean transpose, |
| 1607 const GLfloat* value); | 1612 const GLfloat* value); |
| 1608 void DoUniformMatrix2x4fv( | 1613 void DoUniformMatrix2x4fv( |
| 1609 GLint fake_location, GLsizei count, GLboolean transpose, | 1614 GLint fake_location, GLsizei count, GLboolean transpose, |
| 1610 const GLfloat* value); | 1615 const GLfloat* value); |
| 1611 void DoUniformMatrix3x2fv( | 1616 void DoUniformMatrix3x2fv( |
| 1612 GLint fake_location, GLsizei count, GLboolean transpose, | 1617 GLint fake_location, GLsizei count, GLboolean transpose, |
| 1613 const GLfloat* value); | 1618 const GLfloat* value); |
| 1614 void DoUniformMatrix3x4fv( | 1619 void DoUniformMatrix3x4fv( |
| (...skipping 5824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7439 "glUniformMatrix4fv", | 7444 "glUniformMatrix4fv", |
| 7440 Program::kUniformMatrix4f, | 7445 Program::kUniformMatrix4f, |
| 7441 &real_location, | 7446 &real_location, |
| 7442 &type, | 7447 &type, |
| 7443 &count)) { | 7448 &count)) { |
| 7444 return; | 7449 return; |
| 7445 } | 7450 } |
| 7446 glUniformMatrix4fv(real_location, count, transpose, value); | 7451 glUniformMatrix4fv(real_location, count, transpose, value); |
| 7447 } | 7452 } |
| 7448 | 7453 |
| 7454 void GLES2DecoderImpl::DoUniformMatrix4fvWithCustomMatrixCHROMIUM( | |
| 7455 GLint fake_location, | |
| 7456 GLsizei count, | |
| 7457 GLint custom_matrix_id, | |
| 7458 GLboolean transpose, | |
| 7459 const GLfloat* default_value) { | |
| 7460 // We override exactly one 4x4 matrix. Dropping this parameter doesn't seem | |
| 7461 // 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.
| |
| 7462 if (count != 1) | |
| 7463 return; | |
| 7464 | |
| 7465 float gl_matrix[16]; | |
| 7466 bool copied_matrix = false; | |
| 7467 | |
| 7468 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.
| |
| 7469 // This refers to the bound external texture on the active unit. | |
| 7470 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; | |
| 7471 if (TextureRef* texture_ref = unit.bound_texture_external_oes.get()) { | |
| 7472 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.
| |
| 7473 GL_TEXTURE_EXTERNAL_OES, 0)) { | |
| 7474 copied_matrix = image->GetCustomMatrix(custom_matrix_id, gl_matrix); | |
| 7475 } | |
| 7476 } | |
| 7477 } | |
| 7478 // If the matrix was unsupported, then supply the default. | |
| 7479 // TODO(liberato): remove |default_value| and replace with an identity matrix. | |
| 7480 // It is only present as a transitionary step until StreamTexture supplies | |
| 7481 // the matrix via GLImage. Once that happens, GLRenderer can quit sending | |
| 7482 // in a default. | |
| 7483 if (!copied_matrix) | |
| 7484 memcpy(gl_matrix, default_value, sizeof(gl_matrix)); | |
| 7485 | |
| 7486 GLenum type = 0; | |
| 7487 GLint real_location = -1; | |
| 7488 if (!PrepForSetUniformByLocation(fake_location, "glUniformMatrix4fv", | |
| 7489 Program::kUniformMatrix4f, &real_location, | |
| 7490 &type, &count)) { | |
| 7491 return; | |
| 7492 } | |
| 7493 | |
| 7494 glUniformMatrix4fv(real_location, count, transpose, gl_matrix); | |
| 7495 } | |
| 7496 | |
| 7449 void GLES2DecoderImpl::DoUniformMatrix2x3fv( | 7497 void GLES2DecoderImpl::DoUniformMatrix2x3fv( |
| 7450 GLint fake_location, GLsizei count, GLboolean transpose, | 7498 GLint fake_location, GLsizei count, GLboolean transpose, |
| 7451 const GLfloat* value) { | 7499 const GLfloat* value) { |
| 7452 GLenum type = 0; | 7500 GLenum type = 0; |
| 7453 GLint real_location = -1; | 7501 GLint real_location = -1; |
| 7454 if (!PrepForSetUniformByLocation(fake_location, | 7502 if (!PrepForSetUniformByLocation(fake_location, |
| 7455 "glUniformMatrix2x3fv", | 7503 "glUniformMatrix2x3fv", |
| 7456 Program::kUniformMatrix2x3f, | 7504 Program::kUniformMatrix2x3f, |
| 7457 &real_location, | 7505 &real_location, |
| 7458 &type, | 7506 &type, |
| (...skipping 5918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13377 if (image->CopyTexImage(dest_target)) | 13425 if (image->CopyTexImage(dest_target)) |
| 13378 return; | 13426 return; |
| 13379 } | 13427 } |
| 13380 | 13428 |
| 13381 DoCopyTexImageIfNeeded(source_texture, source_target); | 13429 DoCopyTexImageIfNeeded(source_texture, source_target); |
| 13382 | 13430 |
| 13383 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix | 13431 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix |
| 13384 // before presenting. | 13432 // before presenting. |
| 13385 if (source_target == GL_TEXTURE_EXTERNAL_OES) { | 13433 if (source_target == GL_TEXTURE_EXTERNAL_OES) { |
| 13386 // TODO(hkuang): get the StreamTexture transform matrix in GPU process | 13434 // TODO(hkuang): get the StreamTexture transform matrix in GPU process |
| 13387 // instead of using kIdentityMatrix crbug.com/226218. | 13435 // instead of using kIdentityMatrix crbug.com/226218. AVDACodecImage does |
| 13436 // this correctly, but others (e.g., stream_texture_android.cc) don't. | |
| 13437 GLfloat transform_matrix[16]; | |
| 13438 bool got_matrix = false; | |
| 13439 if (gl::GLImage* image = | |
| 13440 source_texture->GetLevelImage(GL_TEXTURE_EXTERNAL_OES, 0)) { | |
| 13441 got_matrix = image->GetCustomMatrix(12345 /* TODO(liberato): enum */, | |
| 13442 transform_matrix); | |
| 13443 } | |
| 13444 if (!got_matrix) | |
| 13445 memcpy(transform_matrix, kIdentityMatrix, sizeof(transform_matrix)); | |
| 13388 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( | 13446 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( |
| 13389 this, source_target, source_texture->service_id(), | 13447 this, source_target, source_texture->service_id(), dest_target, |
| 13390 dest_target, dest_texture->service_id(), source_width, source_height, | 13448 dest_texture->service_id(), source_width, source_height, |
| 13391 unpack_flip_y == GL_TRUE, | 13449 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE, |
| 13392 unpack_premultiply_alpha == GL_TRUE, | 13450 unpack_unmultiply_alpha == GL_TRUE, transform_matrix); |
| 13393 unpack_unmultiply_alpha == GL_TRUE, | |
| 13394 kIdentityMatrix); | |
| 13395 } else { | 13451 } else { |
| 13396 copy_texture_CHROMIUM_->DoCopyTexture( | 13452 copy_texture_CHROMIUM_->DoCopyTexture( |
| 13397 this, source_target, source_texture->service_id(), | 13453 this, source_target, source_texture->service_id(), |
| 13398 source_internal_format, dest_target, dest_texture->service_id(), | 13454 source_internal_format, dest_target, dest_texture->service_id(), |
| 13399 internal_format, source_width, source_height, | 13455 internal_format, source_width, source_height, |
| 13400 unpack_flip_y == GL_TRUE, | 13456 unpack_flip_y == GL_TRUE, |
| 13401 unpack_premultiply_alpha == GL_TRUE, | 13457 unpack_premultiply_alpha == GL_TRUE, |
| 13402 unpack_unmultiply_alpha == GL_TRUE); | 13458 unpack_unmultiply_alpha == GL_TRUE); |
| 13403 } | 13459 } |
| 13404 } | 13460 } |
| (...skipping 2249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 15654 } | 15710 } |
| 15655 | 15711 |
| 15656 // Include the auto-generated part of this file. We split this because it means | 15712 // Include the auto-generated part of this file. We split this because it means |
| 15657 // we can easily edit the non-auto generated parts right here in this file | 15713 // we can easily edit the non-auto generated parts right here in this file |
| 15658 // instead of having to edit some template or the code generator. | 15714 // instead of having to edit some template or the code generator. |
| 15659 #include "base/macros.h" | 15715 #include "base/macros.h" |
| 15660 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 15716 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 15661 | 15717 |
| 15662 } // namespace gles2 | 15718 } // namespace gles2 |
| 15663 } // namespace gpu | 15719 } // namespace gpu |
| OLD | NEW |