| 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 #ifndef REMOTING_CLIENT_OPENGL_GL_MATH_H_ | 5 #ifndef REMOTING_CLIENT_OPENGL_GL_MATH_H_ |
| 6 #define REMOTING_CLIENT_OPENGL_GL_MATH_H_ | 6 #define REMOTING_CLIENT_OPENGL_GL_MATH_H_ |
| 7 | 7 |
| 8 #include <array> | 8 #include <array> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 | 12 |
| 13 namespace remoting { | 13 namespace remoting { |
| 14 | 14 |
| 15 // See GlCanvas::SetNormalizedTransformation for definition of the | 15 // See GlCanvas::SetNormalizedTransformation for definition of the |
| 16 // transformation matrix. | 16 // transformation matrix. |
| 17 // | 17 // |
| 18 // Converts a pixel based transformation matrix to a texture coordinates based | 18 // Converts a pixel based transformation matrix to a **transposed** texture |
| 19 // transformation matrix. | 19 // coordinates based transformation matrix. |
| 20 // 3 by 3 transformation matrix, [ m0, m1, m2, m3, m4, m5, m6, m7, m8 ]. | 20 // 3 by 3 transformation matrix, [ m0, 0, m2, 0, m4, m5, 0, 0, m8 ]. |
| 21 // | 21 // |
| 22 // | m0, m1, m2, | | x | | 22 // | m0, 0, m2, | | x | |
| 23 // | m3, m4, m5, | * | y | | 23 // | 0, m4, m5, | * | y | |
| 24 // | m6, m7, m8 | | 1 | | 24 // | 0, 0, m8 | | 1 | |
| 25 // |
| 26 // m1, m3, m6, m7 all must be zero. |
| 25 void NormalizeTransformationMatrix(int view_width, | 27 void NormalizeTransformationMatrix(int view_width, |
| 26 int view_height, | 28 int view_height, |
| 27 int canvas_width, | 29 int canvas_width, |
| 28 int canvas_height, | 30 int canvas_height, |
| 29 std::array<float, 9>* matrix); | 31 std::array<float, 9>* matrix); |
| 30 | 32 |
| 31 // Given left, top, width, height of a rectangle, fills |positions| with | 33 // Given left, top, width, height of a rectangle, fills |positions| with |
| 32 // coordinates of four vertices of the rectangle. | 34 // coordinates of four vertices of the rectangle. |
| 33 // positions: [ x_upperleft, y_upperleft, x_lowerleft, y_lowerleft, | 35 // positions: [ x_upperleft, y_upperleft, x_lowerleft, y_lowerleft, |
| 34 // x_upperright, y_upperright, x_lowerright, y_lowerright ] | 36 // x_upperright, y_upperright, x_lowerright, y_lowerright ] |
| 35 void FillRectangleVertexPositions(float left, | 37 void FillRectangleVertexPositions(float left, |
| 36 float top, | 38 float top, |
| 37 float width, | 39 float width, |
| 38 float height, | 40 float height, |
| 39 std::array<float, 8>* positions); | 41 std::array<float, 8>* positions); |
| 40 | 42 |
| 41 // Returns the string representation of the matrix for debugging. | 43 // Returns the string representation of the matrix for debugging. |
| 42 // | 44 // |
| 43 // For example: | 45 // For example: |
| 44 // [ | 46 // [ |
| 45 // 1, 0, 0, | 47 // 1, 0, 0, |
| 46 // 0, 1, 0, | 48 // 0, 1, 0, |
| 47 // 0, 0, 1, | 49 // 0, 0, 1, |
| 48 // ] | 50 // ] |
| 49 std::string MatrixToString(const float* mat, int num_rows, int num_cols); | 51 std::string MatrixToString(const float* mat, int num_rows, int num_cols); |
| 50 | 52 |
| 51 } // namespace remoting | 53 } // namespace remoting |
| 52 | 54 |
| 53 #endif // REMOTING_CLIENT_OPENGL_GL_MATH_H_ | 55 #endif // REMOTING_CLIENT_OPENGL_GL_MATH_H_ |
| OLD | NEW |