Index: remoting/client/viewport_geometry.cc |
diff --git a/remoting/client/viewport_geometry.cc b/remoting/client/viewport_geometry.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..0c75aee4409e9d66633b6385213c9cef4fc630da |
--- /dev/null |
+++ b/remoting/client/viewport_geometry.cc |
@@ -0,0 +1,25 @@ |
+// 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. |
+ |
+#include "remoting/client/viewport_geometry.h" |
+ |
+namespace remoting { |
+ |
+Point ConstrainPointToBounds(const Bounds& bounds, const Point& point) { |
+ Point new_point = point; |
+ if (new_point.x < bounds.left) { |
+ new_point.x = bounds.left; |
+ } else if (new_point.x > bounds.right) { |
+ new_point.x = bounds.right; |
+ } |
+ |
+ if (new_point.y < bounds.top) { |
+ new_point.y = bounds.top; |
+ } else if (new_point.y > bounds.bottom) { |
+ new_point.y = bounds.bottom; |
+ } |
+ return new_point; |
+} |
+ |
+} // namespace remoting |