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 7599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7610 &type, | 7610 &type, |
7611 &count)) { | 7611 &count)) { |
7612 return; | 7612 return; |
7613 } | 7613 } |
7614 glUniformMatrix4fv(real_location, count, transpose, value); | 7614 glUniformMatrix4fv(real_location, count, transpose, value); |
7615 } | 7615 } |
7616 | 7616 |
7617 void GLES2DecoderImpl::DoUniformMatrix4fvStreamTextureMatrixCHROMIUM( | 7617 void GLES2DecoderImpl::DoUniformMatrix4fvStreamTextureMatrixCHROMIUM( |
7618 GLint fake_location, | 7618 GLint fake_location, |
7619 GLboolean transpose, | 7619 GLboolean transpose, |
7620 const GLfloat* default_value) { | 7620 const GLfloat* transform) { |
7621 float gl_matrix[16]; | 7621 float gl_matrix[16]; |
7622 | 7622 |
7623 // If we can't get a matrix from the texture, then use a default. | |
7624 // TODO(liberato): remove |default_value| and replace with an identity matrix. | |
7625 // It is only present as a transitionary step until StreamTexture supplies | |
7626 // the matrix via GLImage. Once that happens, GLRenderer can quit sending | |
7627 // in a default. | |
7628 memcpy(gl_matrix, default_value, sizeof(gl_matrix)); | |
7629 | |
7630 // This refers to the bound external texture on the active unit. | 7623 // This refers to the bound external texture on the active unit. |
7631 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; | 7624 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; |
7632 if (TextureRef* texture_ref = unit.bound_texture_external_oes.get()) { | 7625 if (TextureRef* texture_ref = unit.bound_texture_external_oes.get()) { |
7633 if (GLStreamTextureImage* image = | 7626 if (GLStreamTextureImage* image = |
7634 texture_ref->texture()->GetLevelStreamTextureImage( | 7627 texture_ref->texture()->GetLevelStreamTextureImage( |
7635 GL_TEXTURE_EXTERNAL_OES, 0)) { | 7628 GL_TEXTURE_EXTERNAL_OES, 0)) { |
7636 image->GetTextureMatrix(gl_matrix); | 7629 image->GetTextureMatrix(gl_matrix); |
7630 GLfloat tmp[16]; | |
7631 for (int c = 0; c < 16; c += 4) { | |
7632 for (int r = 0; r < 4; ++r) { | |
no sievers
2016/04/01 21:39:53
Can you use gfx::Transform for the multiplication?
no sievers
2016/04/11 18:08:50
^^ what about this?
Tobias Sargeant
2016/04/12 11:05:24
I've reimplemented with gfx::Transform. WDYT?
| |
7633 tmp[c + r] = 0.0f; | |
7634 for (int i = 0; i < 4; ++i) { | |
7635 tmp[c + r] += gl_matrix[r + 4 * i] * transform[c + i]; | |
7636 } | |
7637 } | |
7638 } | |
7639 std::copy(tmp, tmp + 16, gl_matrix); | |
7640 } else { | |
7641 // Missing stream texture. Treat matrix as identity. | |
7642 memcpy(gl_matrix, transform, sizeof(gl_matrix)); | |
7637 } | 7643 } |
7638 } else { | 7644 } else { |
7639 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, | 7645 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, |
7640 "DoUniformMatrix4vStreamTextureMatrix", | 7646 "DoUniformMatrix4vStreamTextureMatrix", |
7641 "no texture bound"); | 7647 "no texture bound"); |
7642 return; | 7648 return; |
7643 } | 7649 } |
7644 | 7650 |
7645 GLenum type = 0; | 7651 GLenum type = 0; |
7646 GLint real_location = -1; | 7652 GLint real_location = -1; |
(...skipping 6263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13910 } | 13916 } |
13911 | 13917 |
13912 DoCopyTexImageIfNeeded(source_texture, source_target); | 13918 DoCopyTexImageIfNeeded(source_texture, source_target); |
13913 | 13919 |
13914 // GL_TEXTURE_EXTERNAL_OES texture requires that we apply a transform matrix | 13920 // GL_TEXTURE_EXTERNAL_OES texture requires that we apply a transform matrix |
13915 // before presenting. | 13921 // before presenting. |
13916 if (source_target == GL_TEXTURE_EXTERNAL_OES) { | 13922 if (source_target == GL_TEXTURE_EXTERNAL_OES) { |
13917 if (GLStreamTextureImage* image = | 13923 if (GLStreamTextureImage* image = |
13918 source_texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES, | 13924 source_texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES, |
13919 0)) { | 13925 0)) { |
13920 // The coordinate system of this matrix is y-up, not y-down, so a flip is | |
13921 // needed. | |
13922 GLfloat transform_matrix[16]; | 13926 GLfloat transform_matrix[16]; |
13923 image->GetFlippedTextureMatrix(transform_matrix); | 13927 image->GetTextureMatrix(transform_matrix); |
13924 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( | 13928 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( |
13925 this, source_target, source_texture->service_id(), dest_target, | 13929 this, source_target, source_texture->service_id(), dest_target, |
13926 dest_texture->service_id(), source_width, source_height, | 13930 dest_texture->service_id(), source_width, source_height, |
13927 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE, | 13931 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE, |
13928 unpack_unmultiply_alpha == GL_TRUE, transform_matrix); | 13932 unpack_unmultiply_alpha == GL_TRUE, transform_matrix); |
13929 return; | 13933 return; |
13930 } | 13934 } |
13931 } | 13935 } |
13932 copy_texture_CHROMIUM_->DoCopyTexture( | 13936 copy_texture_CHROMIUM_->DoCopyTexture( |
13933 this, source_target, source_texture->service_id(), source_internal_format, | 13937 this, source_target, source_texture->service_id(), source_internal_format, |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
14104 | 14108 |
14105 DoCopyTexImageIfNeeded(source_texture, source_target); | 14109 DoCopyTexImageIfNeeded(source_texture, source_target); |
14106 | 14110 |
14107 | 14111 |
14108 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix | 14112 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix |
14109 // before presenting. | 14113 // before presenting. |
14110 if (source_target == GL_TEXTURE_EXTERNAL_OES) { | 14114 if (source_target == GL_TEXTURE_EXTERNAL_OES) { |
14111 if (GLStreamTextureImage* image = | 14115 if (GLStreamTextureImage* image = |
14112 source_texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES, | 14116 source_texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES, |
14113 0)) { | 14117 0)) { |
14114 // The coordinate system of this matrix is y-up, not y-down, so a flip is | |
14115 // needed. | |
14116 GLfloat transform_matrix[16]; | 14118 GLfloat transform_matrix[16]; |
14117 image->GetFlippedTextureMatrix(transform_matrix); | 14119 image->GetTextureMatrix(transform_matrix); |
14118 copy_texture_CHROMIUM_->DoCopySubTextureWithTransform( | 14120 copy_texture_CHROMIUM_->DoCopySubTextureWithTransform( |
14119 this, source_target, source_texture->service_id(), | 14121 this, source_target, source_texture->service_id(), |
14120 source_internal_format, dest_target, dest_texture->service_id(), | 14122 source_internal_format, dest_target, dest_texture->service_id(), |
14121 dest_internal_format, xoffset, yoffset, x, y, width, height, | 14123 dest_internal_format, xoffset, yoffset, x, y, width, height, |
14122 dest_width, dest_height, source_width, source_height, | 14124 dest_width, dest_height, source_width, source_height, |
14123 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE, | 14125 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE, |
14124 unpack_unmultiply_alpha == GL_TRUE, transform_matrix); | 14126 unpack_unmultiply_alpha == GL_TRUE, transform_matrix); |
14125 return; | 14127 return; |
14126 } | 14128 } |
14127 } | 14129 } |
(...skipping 2249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
16377 } | 16379 } |
16378 | 16380 |
16379 // Include the auto-generated part of this file. We split this because it means | 16381 // Include the auto-generated part of this file. We split this because it means |
16380 // we can easily edit the non-auto generated parts right here in this file | 16382 // we can easily edit the non-auto generated parts right here in this file |
16381 // instead of having to edit some template or the code generator. | 16383 // instead of having to edit some template or the code generator. |
16382 #include "base/macros.h" | 16384 #include "base/macros.h" |
16383 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 16385 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
16384 | 16386 |
16385 } // namespace gles2 | 16387 } // namespace gles2 |
16386 } // namespace gpu | 16388 } // namespace gpu |
OLD | NEW |