| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "remoting/client/gl_canvas.h" | 5 #include "remoting/client/gl_canvas.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "remoting/client/gl_helpers.h" | 8 #include "remoting/client/gl_helpers.h" |
| 9 #include "remoting/client/gl_math.h" |
| 9 | 10 |
| 10 namespace { | 11 namespace { |
| 11 | 12 |
| 12 const int kVertexSize = 2; | 13 const int kVertexSize = 2; |
| 13 const int kVertexCount = 4; | 14 const int kVertexCount = 4; |
| 14 | 15 |
| 15 const char kTexCoordToViewVert[] = | 16 const char kTexCoordToViewVert[] = |
| 16 // Region of the texture to be used (normally the whole texture). | 17 // Region of the texture to be used (normally the whole texture). |
| 17 "varying vec2 v_texCoord;\n" | 18 "varying vec2 v_texCoord;\n" |
| 18 "attribute vec2 a_texCoord;\n" | 19 "attribute vec2 a_texCoord;\n" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 glDisable(GL_BLEND); | 78 glDisable(GL_BLEND); |
| 78 glDisableVertexAttribArray(tex_cord_location_); | 79 glDisableVertexAttribArray(tex_cord_location_); |
| 79 glDisableVertexAttribArray(position_location_); | 80 glDisableVertexAttribArray(position_location_); |
| 80 glDeleteProgram(program_); | 81 glDeleteProgram(program_); |
| 81 glDeleteShader(vertex_shader_); | 82 glDeleteShader(vertex_shader_); |
| 82 glDeleteShader(fragment_shader_); | 83 glDeleteShader(fragment_shader_); |
| 83 } | 84 } |
| 84 | 85 |
| 85 void GlCanvas::SetNormalizedTransformation(const std::array<float, 9>& matrix) { | 86 void GlCanvas::SetNormalizedTransformation(const std::array<float, 9>& matrix) { |
| 86 DCHECK(thread_checker_.CalledOnValidThread()); | 87 DCHECK(thread_checker_.CalledOnValidThread()); |
| 87 glUniformMatrix3fv(transform_location_, 1, GL_TRUE, matrix.data()); | 88 std::array<float, 9> transposed_matrix = matrix; |
| 89 TransposeTransformationMatrix(&transposed_matrix); |
| 90 glUniformMatrix3fv(transform_location_, 1, GL_FALSE, |
| 91 transposed_matrix.data()); |
| 88 transformation_set_ = true; | 92 transformation_set_ = true; |
| 89 } | 93 } |
| 90 | 94 |
| 91 void GlCanvas::DrawTexture(int texture_id, | 95 void GlCanvas::DrawTexture(int texture_id, |
| 92 GLuint texture_handle, | 96 GLuint texture_handle, |
| 93 GLuint vertex_buffer, | 97 GLuint vertex_buffer, |
| 94 float alpha_multiplier) { | 98 float alpha_multiplier) { |
| 95 DCHECK(thread_checker_.CalledOnValidThread()); | 99 DCHECK(thread_checker_.CalledOnValidThread()); |
| 96 if (!transformation_set_) { | 100 if (!transformation_set_) { |
| 97 return; | 101 return; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 110 glDrawArrays(GL_TRIANGLE_STRIP, 0, kVertexCount); | 114 glDrawArrays(GL_TRIANGLE_STRIP, 0, kVertexCount); |
| 111 glBindBuffer(GL_ARRAY_BUFFER, 0); | 115 glBindBuffer(GL_ARRAY_BUFFER, 0); |
| 112 glBindTexture(GL_TEXTURE_2D, 0); | 116 glBindTexture(GL_TEXTURE_2D, 0); |
| 113 } | 117 } |
| 114 | 118 |
| 115 int GlCanvas::GetGlVersion() const { | 119 int GlCanvas::GetGlVersion() const { |
| 116 return gl_version_; | 120 return gl_version_; |
| 117 } | 121 } |
| 118 | 122 |
| 119 } // namespace remoting | 123 } // namespace remoting |
| OLD | NEW |