Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef REMOTING_CLIENT_OPENGL_GL_MATH_H_ | |
| 6 #define REMOTING_CLIENT_OPENGL_GL_MATH_H_ | |
| 7 | |
| 8 #include <array> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/macros.h" | |
| 12 | |
| 13 namespace remoting { | |
| 14 | |
| 15 // See GlCanvas::SetNormalizedTransformation for definition of the | |
| 16 // transformation matrix. | |
| 17 // | |
| 18 // Converts a pixel based transformation matrix to a texture coordinates based | |
| 19 // transformation matrix. | |
| 20 // 3 by 3 transformation matrix, [ m0, m1, m2, m3, m4, m5, m6, m7, m8 ]. | |
| 21 // | |
| 22 // | m0, m1, m2, | | x | | |
| 23 // | m3, m4, m5, | * | y | | |
| 24 // | m6, m7, m8 | | 1 | | |
| 25 void NormalizeTransformationMatrix(std::array<float, 9>& mat, | |
|
Sergey Ulanov
2016/07/19 00:42:48
matrix
Sergey Ulanov
2016/07/19 00:42:48
use pointer instead of a reference here and move t
Yuwei
2016/07/19 20:34:24
Done.
| |
| 26 int view_width, | |
| 27 int view_height, | |
| 28 int canvas_width, | |
| 29 int canvas_height); | |
| 30 | |
| 31 // Given left, top, width, height of a rectangle, fills |positions| with | |
| 32 // coordinates of four vertices of the rectangle. | |
| 33 // positions: [ x_upperleft, y_upperleft, x_lowerleft, y_lowerleft, | |
| 34 // x_upperright, y_upperright, x_lowerright, y_lowerright ] | |
| 35 void FillRectangleVertexPositions(std::array<float, 8>& positions, | |
| 36 float left, | |
| 37 float top, | |
| 38 float width, | |
| 39 float height); | |
| 40 | |
| 41 // interpolates vector |dest| between [vec1, vec2]. | |
| 42 // dest = (1 - percent) * vec1 + percent * vec2 | |
| 43 // dimension: length of dest, vec1, vec2 | |
| 44 template<typename NumberType> | |
| 45 void LinearInterpolate(NumberType* dest, | |
|
Sergey Ulanov
2016/07/19 00:42:48
Do you need this as a template? It's used in only
Yuwei
2016/07/19 20:34:23
Obsolete. Removed.
| |
| 46 const NumberType* vec1, | |
| 47 const NumberType* vec2, | |
| 48 float percent, | |
| 49 int dimension) { | |
| 50 for (int i = 0; i < dimension; i++) { | |
| 51 dest[i] = (1.f - percent) * vec1[i] + percent * vec2[i]; | |
|
Sergey Ulanov
2016/07/19 00:42:48
you convert values from int to float and then back
Yuwei
2016/07/19 04:11:52
Maybe something like:
((100 - percent) * vec1[i]
Yuwei
2016/07/19 20:34:23
Removed.
| |
| 52 } | |
| 53 } | |
| 54 | |
| 55 // Returns the string representation of the matrix for debugging. | |
| 56 // | |
| 57 // For example: | |
| 58 // [ | |
| 59 // 1, 0, 0, | |
| 60 // 0, 1, 0, | |
| 61 // 0, 0, 1, | |
| 62 // ] | |
| 63 std::string MatrixToString(const float* mat, int num_rows, int num_cols); | |
| 64 | |
| 65 } // namespace remoting | |
| 66 | |
| 67 #endif // REMOTING_CLIENT_OPENGL_GL_MATH_H_ | |
| OLD | NEW |