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

Unified Diff: remoting/client/simple_matrix.h

Issue 2843373005: [Remoting Client] DesktopViewport Implementation (Closed)
Patch Set: Fix Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: remoting/client/simple_matrix.h
diff --git a/remoting/client/simple_matrix.h b/remoting/client/simple_matrix.h
new file mode 100644
index 0000000000000000000000000000000000000000..2ceb7a3fbdd33edf0dbe25c8fa8fbde05aae0255
--- /dev/null
+++ b/remoting/client/simple_matrix.h
@@ -0,0 +1,57 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef REMOTING_CLIENT_SIMPLE_MATRIX_H_
+#define REMOTING_CLIENT_SIMPLE_MATRIX_H_
joedow 2017/04/28 21:29:53 Maybe just call this matrix? It isn't clear why i
Yuwei 2017/04/28 23:53:41 I called it simple because it only needs 3 paramet
+
+#include "remoting/client/viewport_geometry.h"
+
+namespace remoting {
+
+// A 2D non-skew equally scaled transformation matrix.
+// | SCALE, 0, OFFSET_X, |
+// | 0, SCALE, OFFSET_Y, |
+// | 0, 0, 1 |
+class SimpleMatrix {
Yuwei 2017/04/28 02:10:51 It's possible to use Skia to do matrix calculation
joedow 2017/04/28 21:29:53 I think saving ~1MB is a good reason since our pac
+ public:
+ SimpleMatrix(float scale, const Vector2D& offset);
+
+ ~SimpleMatrix();
+
+ // Applies the matrix on the point and returns the result.
+ Point MapPoint(const Point& point) const;
+
+ // Applies the matrix on the vector and returns the result. This only scales
+ // the vector and does not apply offset.
+ Vector2D MapVector(const Vector2D& vector) const;
+
+ // Sets the scale factor, with the pivot point at (0, 0). This WON'T affect
+ // the offset.
+ void SetScale(float scale);
+
+ // Returns the scale of this matrix.
+ float GetScale() const;
+
+ // Adjust the matrix M to M' such that:
+ // M * p_a = p_b => M' * p_a = scale * (p_b - pivot) + pivot
+ void PostScale(const Point& pivot, float scale);
+
+ // Applies translation to the matrix.
+ // M * p_a = p_b => M' * p_a = p_b + delta
+ void PostTranslate(const Vector2D& delta);
+
+ // Returns the inverse of this matrix.
+ SimpleMatrix Invert() const;
+
+ // Converts to the 3x3 matrix array.
+ std::array<float, 9> ToMatrixArray() const;
+
+ private:
+ float scale_;
+ Vector2D offset_;
+};
+
+} // namespace remoting
+
+#endif // REMOTING_CLIENT_SIMPLE_MATRIX_H_

Powered by Google App Engine
This is Rietveld 408576698