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_math.h" | 5 #include "remoting/client/gl_math.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 namespace { | 9 namespace { |
10 | 10 |
11 // | m0, m1, m2, | | Scale_x 0 Offset_x | | 11 // | m0, m1, m2, | | Scale_x 0 Offset_x | |
12 // | m3, m4, m5, | = | 0 Scale_y Offset_y | | 12 // | m3, m4, m5, | = | 0 Scale_y Offset_y | |
13 // | m6, m7, m8 | | 0 0 1 | | 13 // | m6, m7, m8 | | 0 0 1 | |
14 | 14 |
15 const int kXScaleKey = 0; | 15 const int kXScaleKey = 0; |
16 const int kYScaleKey = 4; | 16 const int kYScaleKey = 4; |
17 const int kXOffsetKey = 2; | 17 const int kXOffsetKey = 2; |
18 const int kYOffsetKey = 5; | 18 const int kYOffsetKey = 5; |
| 19 const int kXOffsetKeyTransposed = 6; |
| 20 const int kYOffsetKeyTransposed = 7; |
19 | 21 |
20 } // namespace | 22 } // namespace |
21 | 23 |
22 namespace remoting { | 24 namespace remoting { |
23 | 25 |
24 void NormalizeTransformationMatrix(int view_width, | 26 void NormalizeTransformationMatrix(int view_width, |
25 int view_height, | 27 int view_height, |
26 int canvas_width, | 28 int canvas_width, |
27 int canvas_height, | 29 int canvas_height, |
28 std::array<float, 9>* matrix) { | 30 std::array<float, 9>* matrix) { |
29 (*matrix)[kXScaleKey] = canvas_width * (*matrix)[kXScaleKey] / view_width; | 31 (*matrix)[kXScaleKey] = canvas_width * (*matrix)[kXScaleKey] / view_width; |
30 (*matrix)[kYScaleKey] = canvas_height * (*matrix)[kYScaleKey] / view_height; | 32 (*matrix)[kYScaleKey] = canvas_height * (*matrix)[kYScaleKey] / view_height; |
31 (*matrix)[kXOffsetKey] /= view_width; | 33 (*matrix)[kXOffsetKeyTransposed] = (*matrix)[kXOffsetKey] / view_width; |
32 (*matrix)[kYOffsetKey] /= view_height; | 34 (*matrix)[kYOffsetKeyTransposed] = (*matrix)[kYOffsetKey] / view_height; |
| 35 (*matrix)[kXOffsetKey] = 0; |
| 36 (*matrix)[kYOffsetKey] = 0; |
33 } | 37 } |
34 | 38 |
35 void FillRectangleVertexPositions(float left, | 39 void FillRectangleVertexPositions(float left, |
36 float top, | 40 float top, |
37 float width, | 41 float width, |
38 float height, | 42 float height, |
39 std::array<float, 8>* positions) { | 43 std::array<float, 8>* positions) { |
40 (*positions)[0] = left; | 44 (*positions)[0] = left; |
41 (*positions)[1] = top; | 45 (*positions)[1] = top; |
42 | 46 |
(...skipping 14 matching lines...) Expand all Loading... |
57 for (int j = 0; j < num_cols; j++) { | 61 for (int j = 0; j < num_cols; j++) { |
58 outstream << mat[i * num_cols + j] << ", "; | 62 outstream << mat[i * num_cols + j] << ", "; |
59 } | 63 } |
60 outstream << "\n"; | 64 outstream << "\n"; |
61 } | 65 } |
62 outstream << "]"; | 66 outstream << "]"; |
63 return outstream.str(); | 67 return outstream.str(); |
64 } | 68 } |
65 | 69 |
66 } // namespace remoting | 70 } // namespace remoting |
OLD | NEW |