Chromium Code Reviews| Index: gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.cc |
| diff --git a/gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.cc b/gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.cc |
| index 2591ec811f5784fba099647a210ea550f8ddbd65..ac966de2428ddd81c4c4617d02321872feabbd15 100644 |
| --- a/gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.cc |
| +++ b/gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.cc |
| @@ -54,10 +54,11 @@ struct ShaderInfo { |
| const ShaderInfo shader_infos[] = { |
| // VERTEX_SHADER_POS_TEX |
| SHADER( |
| + uniform mat4 matrix; |
|
greggman
2013/04/08 17:29:47
nit: we've tried to have uniforms start with u_, v
hkuang
2013/04/09 00:49:54
Good style that I need to follow. I did not notice
|
| attribute vec4 a_position; |
| varying vec2 v_uv; |
| void main(void) { |
| - gl_Position = a_position; |
| + gl_Position = matrix * a_position; |
| v_uv = a_position.xy * 0.5 + vec2(0.5, 0.5); |
| }), |
| // FRAGMENT_SHADER_TEX |
| @@ -313,6 +314,29 @@ void CopyTextureCHROMIUMResourceManager::DoCopyTexture( |
| bool flip_y, |
| bool premultiply_alpha, |
| bool unpremultiply_alpha) { |
| + // Use default transform matrix if no transform passed in. |
| + const GLfloat default_matrix[16] = {1.0f, 0.0f, 0.0f, 0.0f, |
|
greggman
2013/04/08 17:29:47
any reason not to make this static? Otherwise code
hkuang
2013/04/09 00:49:54
No reason that I do not make it static.
Done.
On
|
| + 0.0f, 1.0f, 0.0f, 0.0f, |
| + 0.0f, 0.0f, 1.0f, 0.0f, |
| + 0.0f, 0.0f, 0.0f, 1.0f}; |
| + DoCopyTextureWithTransform(decoder, source_target, dest_target, source_id, |
| + dest_id, level, width, height, flip_y, premultiply_alpha, |
| + unpremultiply_alpha, default_matrix); |
| +} |
| + |
| +void CopyTextureCHROMIUMResourceManager::DoCopyTextureWithTransform( |
| + const gles2::GLES2Decoder* decoder, |
| + GLenum source_target, |
| + GLenum dest_target, |
| + GLuint source_id, |
| + GLuint dest_id, |
| + GLint level, |
| + GLsizei width, |
| + GLsizei height, |
| + bool flip_y, |
| + bool premultiply_alpha, |
| + bool unpremultiply_alpha, |
| + const GLfloat transform_matrix[16]) { |
| DCHECK(source_target == GL_TEXTURE_2D || |
| source_target == GL_TEXTURE_EXTERNAL_OES); |
| if (!initialized_) { |
| @@ -335,6 +359,8 @@ void CopyTextureCHROMIUMResourceManager::DoCopyTexture( |
| } |
| #endif |
| + GLuint matrix_handle_ = glGetUniformLocation(programs_[program], "matrix"); |
|
greggman
2013/04/08 17:29:47
Looking up uniforms is slow. this should happen at
hkuang
2013/04/09 00:49:54
Done.
|
| + glUniformMatrix4fv(matrix_handle_, 1, GL_FALSE, transform_matrix); |
| glActiveTexture(GL_TEXTURE0); |
| glBindTexture(GL_TEXTURE_2D, dest_id); |
| // NVidia drivers require texture settings to be a certain way |