Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Side by Side Diff: remoting/client/gl_math.cc

Issue 2175963002: [Chromoting] Implement GlRenderer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reviewer's Feedback Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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)[kXOffsetKey] /= view_width;
32 (*matrix)[kYOffsetKey] /= view_height; 34 (*matrix)[kYOffsetKey] /= view_height;
33 } 35 }
34 36
37 void TransposeTransformationMatrix(std::array<float, 9>* matrix) {
38 (*matrix)[kXOffsetKeyTransposed] = (*matrix)[kXOffsetKey];
39 (*matrix)[kYOffsetKeyTransposed] = (*matrix)[kYOffsetKey];
40 (*matrix)[kXOffsetKey] = 0;
41 (*matrix)[kYOffsetKey] = 0;
42 }
43
35 void FillRectangleVertexPositions(float left, 44 void FillRectangleVertexPositions(float left,
36 float top, 45 float top,
37 float width, 46 float width,
38 float height, 47 float height,
39 std::array<float, 8>* positions) { 48 std::array<float, 8>* positions) {
40 (*positions)[0] = left; 49 (*positions)[0] = left;
41 (*positions)[1] = top; 50 (*positions)[1] = top;
42 51
43 (*positions)[2] = left; 52 (*positions)[2] = left;
44 (*positions)[3] = top + height; 53 (*positions)[3] = top + height;
(...skipping 12 matching lines...) Expand all
57 for (int j = 0; j < num_cols; j++) { 66 for (int j = 0; j < num_cols; j++) {
58 outstream << mat[i * num_cols + j] << ", "; 67 outstream << mat[i * num_cols + j] << ", ";
59 } 68 }
60 outstream << "\n"; 69 outstream << "\n";
61 } 70 }
62 outstream << "]"; 71 outstream << "]";
63 return outstream.str(); 72 return outstream.str();
64 } 73 }
65 74
66 } // namespace remoting 75 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698