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 #include "remoting/client/gl_math.h" | |
6 | |
7 #include <sstream> | |
8 | |
9 namespace { | |
10 | |
11 // | m0, m1, m2, | | Scale_x 0 Offset_x | | |
12 // | m3, m4, m5, | = | 0 Scale_y Offset_y | | |
13 // | m6, m7, m8 | | 0 0 1 | | |
14 | |
15 const int kXScaleKey = 0; | |
16 const int kYScaleKey = 4; | |
17 const int kXOffsetKey = 2; | |
18 const int kYOffsetKey = 5; | |
19 | |
20 } | |
Sergey Ulanov
2016/07/19 00:42:48
// namespace
Yuwei
2016/07/19 20:34:23
Done.
| |
21 | |
22 namespace remoting { | |
23 | |
24 void NormalizeTransformationMatrix(std::array<float, 9>& mat, | |
25 int view_width, | |
26 int view_height, | |
27 int canvas_width, | |
28 int canvas_height) { | |
29 mat[kXScaleKey] = canvas_width * mat[kXScaleKey] / view_width; | |
30 mat[kYScaleKey] = canvas_height * mat[kYScaleKey] / view_height; | |
31 mat[kXOffsetKey] /= view_width; | |
32 mat[kYOffsetKey] /= view_height; | |
33 } | |
34 | |
35 void FillRectangleVertexPositions(std::array<float, 8>& positions, | |
36 float left, | |
37 float top, | |
38 float width, | |
39 float height) { | |
40 positions[0] = left; | |
41 positions[2] = left; | |
42 positions[4] = left + width; | |
43 positions[6] = left + width; | |
44 | |
45 positions[1] = top; | |
Sergey Ulanov
2016/07/19 00:42:48
I think it would be more readable if you filled in
Yuwei
2016/07/19 20:34:23
Done.
| |
46 positions[3] = top + height; | |
47 positions[5] = top; | |
48 positions[7] = top + height; | |
49 } | |
50 | |
51 std::string MatrixToString(const float* mat, int num_rows, int num_cols) { | |
52 std::ostringstream outstream; | |
53 outstream << "[\n"; | |
54 for (int i = 0; i < num_rows; i++) { | |
55 for (int j = 0; j < num_cols; j++) { | |
56 outstream << mat[i*num_cols + j] << ", "; | |
Sergey Ulanov
2016/07/19 00:42:48
spaces around * please. (git cl format?)
Yuwei
2016/07/19 20:34:23
Done.
| |
57 } | |
58 outstream << "\n"; | |
59 } | |
60 outstream << "]"; | |
61 return outstream.str(); | |
62 } | |
63 | |
64 } // namespace remoting | |
OLD | NEW |