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

Side by Side Diff: remoting/client/view_matrix.h

Issue 2843373005: [Remoting Client] DesktopViewport Implementation (Closed)
Patch Set: Rename SimpleMatrix to ViewMatrix Created 3 years, 7 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
« no previous file with comments | « remoting/client/desktop_viewport_unittest.cc ('k') | remoting/client/view_matrix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 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_VIEW_MATRIX_H_
6 #define REMOTING_CLIENT_VIEW_MATRIX_H_
7
8 #include <array>
9
10 namespace remoting {
11
12 // A 2D non-skew equally scaled transformation matrix.
13 // | SCALE, 0, OFFSET_X, |
14 // | 0, SCALE, OFFSET_Y, |
15 // | 0, 0, 1 |
16 class ViewMatrix {
17 public:
18 struct Vector2D {
19 float x;
20 float y;
21 };
22
23 // Same as Vector2D. This alias just serves as a context hint.
24 using Point = Vector2D;
25
26 // Creates an empty matrix (0 scale and offsets).
27 ViewMatrix();
28
29 ViewMatrix(float scale, const Vector2D& offset);
30
31 ~ViewMatrix();
32
33 // Applies the matrix on the point and returns the result.
34 Point MapPoint(const Point& point) const;
35
36 // Applies the matrix on the vector and returns the result. This only scales
37 // the vector and does not apply offset.
38 Vector2D MapVector(const Vector2D& vector) const;
39
40 // Sets the scale factor, with the pivot point at (0, 0). This WON'T affect
41 // the offset.
42 void SetScale(float scale);
43
44 // Returns the scale of this matrix.
45 float GetScale() const;
46
47 // Adjust the matrix M to M' such that:
48 // M * p_a = p_b => M' * p_a = scale * (p_b - pivot) + pivot
49 void PostScale(const Point& pivot, float scale);
50
51 // Applies translation to the matrix.
52 // M * p_a = p_b => M' * p_a = p_b + delta
53 void PostTranslate(const Vector2D& delta);
54
55 // Returns the inverse of this matrix.
56 ViewMatrix Invert() const;
57
58 // Returns true if the scale and offsets are both 0.
59 bool IsEmpty() const;
60
61 // Converts to the 3x3 matrix array.
62 std::array<float, 9> ToMatrixArray() const;
63
64 private:
65 float scale_;
66 Vector2D offset_;
67 };
68
69 } // namespace remoting
70
71 #endif // REMOTING_CLIENT_VIEW_MATRIX_H_
OLDNEW
« no previous file with comments | « remoting/client/desktop_viewport_unittest.cc ('k') | remoting/client/view_matrix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698