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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 #include "ui/gfx/geometry/point.h" | 63 #include "ui/gfx/geometry/point.h" |
64 #include "ui/gfx/geometry/rect.h" | 64 #include "ui/gfx/geometry/rect.h" |
65 #include "ui/gfx/geometry/size.h" | 65 #include "ui/gfx/geometry/size.h" |
66 #include "ui/gfx/overlay_transform.h" | 66 #include "ui/gfx/overlay_transform.h" |
67 #include "ui/gfx/transform.h" | 67 #include "ui/gfx/transform.h" |
68 #include "ui/gl/gl_bindings.h" | 68 #include "ui/gl/gl_bindings.h" |
69 #include "ui/gl/gl_context.h" | 69 #include "ui/gl/gl_context.h" |
70 #include "ui/gl/gl_fence.h" | 70 #include "ui/gl/gl_fence.h" |
71 #include "ui/gl/gl_image.h" | 71 #include "ui/gl/gl_image.h" |
72 #include "ui/gl/gl_implementation.h" | 72 #include "ui/gl/gl_implementation.h" |
73 #include "ui/gl/gl_stream_texture_image.h" | |
73 #include "ui/gl/gl_surface.h" | 74 #include "ui/gl/gl_surface.h" |
74 #include "ui/gl/gl_version_info.h" | 75 #include "ui/gl/gl_version_info.h" |
75 #include "ui/gl/gpu_timing.h" | 76 #include "ui/gl/gpu_timing.h" |
76 | 77 |
77 #if defined(OS_MACOSX) | 78 #if defined(OS_MACOSX) |
78 #include <IOSurface/IOSurface.h> | 79 #include <IOSurface/IOSurface.h> |
79 // Note that this must be included after gl_bindings.h to avoid conflicts. | 80 // Note that this must be included after gl_bindings.h to avoid conflicts. |
80 #include <OpenGL/CGLIOSurface.h> | 81 #include <OpenGL/CGLIOSurface.h> |
81 #endif | 82 #endif |
82 | 83 |
(...skipping 1507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1590 | 1591 |
1591 void DoUniformMatrix2fv( | 1592 void DoUniformMatrix2fv( |
1592 GLint fake_location, GLsizei count, GLboolean transpose, | 1593 GLint fake_location, GLsizei count, GLboolean transpose, |
1593 const GLfloat* value); | 1594 const GLfloat* value); |
1594 void DoUniformMatrix3fv( | 1595 void DoUniformMatrix3fv( |
1595 GLint fake_location, GLsizei count, GLboolean transpose, | 1596 GLint fake_location, GLsizei count, GLboolean transpose, |
1596 const GLfloat* value); | 1597 const GLfloat* value); |
1597 void DoUniformMatrix4fv( | 1598 void DoUniformMatrix4fv( |
1598 GLint fake_location, GLsizei count, GLboolean transpose, | 1599 GLint fake_location, GLsizei count, GLboolean transpose, |
1599 const GLfloat* value); | 1600 const GLfloat* value); |
1601 void DoUniformMatrix4fvWithStreamTextureMatrixCHROMIUM(GLint fake_location, | |
1602 GLboolean transpose, | |
1603 const GLfloat* value); | |
reveman
2016/02/18 20:20:56
nit: s/value/default_value/
liberato (no reviews please)
2016/02/19 18:39:56
Done.
| |
1600 void DoUniformMatrix2x3fv( | 1604 void DoUniformMatrix2x3fv( |
1601 GLint fake_location, GLsizei count, GLboolean transpose, | 1605 GLint fake_location, GLsizei count, GLboolean transpose, |
1602 const GLfloat* value); | 1606 const GLfloat* value); |
1603 void DoUniformMatrix2x4fv( | 1607 void DoUniformMatrix2x4fv( |
1604 GLint fake_location, GLsizei count, GLboolean transpose, | 1608 GLint fake_location, GLsizei count, GLboolean transpose, |
1605 const GLfloat* value); | 1609 const GLfloat* value); |
1606 void DoUniformMatrix3x2fv( | 1610 void DoUniformMatrix3x2fv( |
1607 GLint fake_location, GLsizei count, GLboolean transpose, | 1611 GLint fake_location, GLsizei count, GLboolean transpose, |
1608 const GLfloat* value); | 1612 const GLfloat* value); |
1609 void DoUniformMatrix3x4fv( | 1613 void DoUniformMatrix3x4fv( |
(...skipping 5824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7434 "glUniformMatrix4fv", | 7438 "glUniformMatrix4fv", |
7435 Program::kUniformMatrix4f, | 7439 Program::kUniformMatrix4f, |
7436 &real_location, | 7440 &real_location, |
7437 &type, | 7441 &type, |
7438 &count)) { | 7442 &count)) { |
7439 return; | 7443 return; |
7440 } | 7444 } |
7441 glUniformMatrix4fv(real_location, count, transpose, value); | 7445 glUniformMatrix4fv(real_location, count, transpose, value); |
7442 } | 7446 } |
7443 | 7447 |
7448 void GLES2DecoderImpl::DoUniformMatrix4fvWithStreamTextureMatrixCHROMIUM( | |
7449 GLint fake_location, | |
7450 GLboolean transpose, | |
7451 const GLfloat* default_value) { | |
7452 float gl_matrix[16]; | |
7453 bool copied_matrix = false; | |
reveman
2016/02/18 20:20:56
nit: move the memcpy here and remove this copied_m
liberato (no reviews please)
2016/02/19 18:39:56
Done.
| |
7454 | |
7455 // This refers to the bound external texture on the active unit. | |
7456 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; | |
7457 if (TextureRef* texture_ref = unit.bound_texture_external_oes.get()) { | |
7458 if (gl::GLStreamTextureImage* image = | |
7459 texture_ref->texture()->GetLevelStreamTextureImage( | |
7460 GL_TEXTURE_EXTERNAL_OES, 0)) { | |
7461 image->GetTextureMatrix(gl_matrix); | |
7462 copied_matrix = true; | |
7463 // TODO(liberato): verify cl comments about !image. | |
reveman
2016/02/18 20:20:56
not sure what this refers to
liberato (no reviews please)
2016/02/19 18:39:55
note to myself. i forgot to remove it.
| |
7464 } | |
7465 } | |
7466 | |
7467 // If the matrix was unsupported, then supply the default. | |
7468 // TODO(liberato): remove |default_value| and replace with an identity matrix. | |
7469 // It is only present as a transitionary step until StreamTexture supplies | |
7470 // the matrix via GLImage. Once that happens, GLRenderer can quit sending | |
7471 // in a default. | |
7472 if (!copied_matrix) | |
7473 memcpy(gl_matrix, default_value, sizeof(gl_matrix)); | |
7474 | |
7475 GLenum type = 0; | |
7476 GLint real_location = -1; | |
7477 GLsizei count = 1; | |
7478 if (!PrepForSetUniformByLocation(fake_location, "glUniformMatrix4fv", | |
7479 Program::kUniformMatrix4f, &real_location, | |
7480 &type, &count)) { | |
7481 return; | |
7482 } | |
7483 | |
7484 glUniformMatrix4fv(real_location, count, transpose, gl_matrix); | |
7485 } | |
7486 | |
7444 void GLES2DecoderImpl::DoUniformMatrix2x3fv( | 7487 void GLES2DecoderImpl::DoUniformMatrix2x3fv( |
7445 GLint fake_location, GLsizei count, GLboolean transpose, | 7488 GLint fake_location, GLsizei count, GLboolean transpose, |
7446 const GLfloat* value) { | 7489 const GLfloat* value) { |
7447 GLenum type = 0; | 7490 GLenum type = 0; |
7448 GLint real_location = -1; | 7491 GLint real_location = -1; |
7449 if (!PrepForSetUniformByLocation(fake_location, | 7492 if (!PrepForSetUniformByLocation(fake_location, |
7450 "glUniformMatrix2x3fv", | 7493 "glUniformMatrix2x3fv", |
7451 Program::kUniformMatrix2x3f, | 7494 Program::kUniformMatrix2x3f, |
7452 &real_location, | 7495 &real_location, |
7453 &type, | 7496 &type, |
(...skipping 5900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13354 if (image->CopyTexImage(dest_target)) | 13397 if (image->CopyTexImage(dest_target)) |
13355 return; | 13398 return; |
13356 } | 13399 } |
13357 | 13400 |
13358 DoCopyTexImageIfNeeded(source_texture, source_target); | 13401 DoCopyTexImageIfNeeded(source_texture, source_target); |
13359 | 13402 |
13360 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix | 13403 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix |
13361 // before presenting. | 13404 // before presenting. |
13362 if (source_target == GL_TEXTURE_EXTERNAL_OES) { | 13405 if (source_target == GL_TEXTURE_EXTERNAL_OES) { |
13363 // TODO(hkuang): get the StreamTexture transform matrix in GPU process | 13406 // TODO(hkuang): get the StreamTexture transform matrix in GPU process |
13364 // instead of using kIdentityMatrix crbug.com/226218. | 13407 // instead of using kIdentityMatrix crbug.com/226218. AVDACodecImage does |
13408 // this correctly, but others (e.g., stream_texture_android.cc) don't. | |
13409 GLfloat transform_matrix[16]; | |
13410 bool got_matrix = false; | |
reveman
2016/02/18 20:20:56
nit: same here. move memcpy here instead of this f
liberato (no reviews please)
2016/02/19 18:39:56
Done.
| |
13411 if (gl::GLStreamTextureImage* image = | |
13412 source_texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES, | |
13413 0)) { | |
13414 image->GetTextureMatrix(transform_matrix); | |
13415 got_matrix = true; | |
13416 } | |
13417 if (!got_matrix) | |
13418 memcpy(transform_matrix, kIdentityMatrix, sizeof(transform_matrix)); | |
13365 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( | 13419 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( |
13366 this, source_target, source_texture->service_id(), | 13420 this, source_target, source_texture->service_id(), dest_target, |
13367 dest_target, dest_texture->service_id(), source_width, source_height, | 13421 dest_texture->service_id(), source_width, source_height, |
13368 unpack_flip_y == GL_TRUE, | 13422 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE, |
13369 unpack_premultiply_alpha == GL_TRUE, | 13423 unpack_unmultiply_alpha == GL_TRUE, transform_matrix); |
13370 unpack_unmultiply_alpha == GL_TRUE, | |
13371 kIdentityMatrix); | |
13372 } else { | 13424 } else { |
13373 copy_texture_CHROMIUM_->DoCopyTexture( | 13425 copy_texture_CHROMIUM_->DoCopyTexture( |
13374 this, source_target, source_texture->service_id(), | 13426 this, source_target, source_texture->service_id(), |
13375 source_internal_format, dest_target, dest_texture->service_id(), | 13427 source_internal_format, dest_target, dest_texture->service_id(), |
13376 internal_format, source_width, source_height, | 13428 internal_format, source_width, source_height, |
13377 unpack_flip_y == GL_TRUE, | 13429 unpack_flip_y == GL_TRUE, |
13378 unpack_premultiply_alpha == GL_TRUE, | 13430 unpack_premultiply_alpha == GL_TRUE, |
13379 unpack_unmultiply_alpha == GL_TRUE); | 13431 unpack_unmultiply_alpha == GL_TRUE); |
13380 } | 13432 } |
13381 } | 13433 } |
(...skipping 2365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15747 } | 15799 } |
15748 | 15800 |
15749 // Include the auto-generated part of this file. We split this because it means | 15801 // Include the auto-generated part of this file. We split this because it means |
15750 // we can easily edit the non-auto generated parts right here in this file | 15802 // we can easily edit the non-auto generated parts right here in this file |
15751 // instead of having to edit some template or the code generator. | 15803 // instead of having to edit some template or the code generator. |
15752 #include "base/macros.h" | 15804 #include "base/macros.h" |
15753 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 15805 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
15754 | 15806 |
15755 } // namespace gles2 | 15807 } // namespace gles2 |
15756 } // namespace gpu | 15808 } // namespace gpu |
OLD | NEW |