| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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/ui/desktop_viewport.h" | 5 #include "remoting/client/ui/desktop_viewport.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 | 10 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 62 |
| 63 ViewMatrix::Point DesktopViewport::GetViewportCenter() const { | 63 ViewMatrix::Point DesktopViewport::GetViewportCenter() const { |
| 64 if (!IsViewportReady()) { | 64 if (!IsViewportReady()) { |
| 65 LOG(WARNING) << "Viewport is not ready before getting the viewport center"; | 65 LOG(WARNING) << "Viewport is not ready before getting the viewport center"; |
| 66 return {0.f, 0.f}; | 66 return {0.f, 0.f}; |
| 67 } | 67 } |
| 68 return desktop_to_surface_transform_.Invert().MapPoint( | 68 return desktop_to_surface_transform_.Invert().MapPoint( |
| 69 {surface_size_.x / 2.f, surface_size_.y / 2.f}); | 69 {surface_size_.x / 2.f, surface_size_.y / 2.f}); |
| 70 } | 70 } |
| 71 | 71 |
| 72 bool DesktopViewport::IsPointWithinDesktopBounds( |
| 73 const ViewMatrix::Point& point) const { |
| 74 if (!IsViewportReady()) { |
| 75 LOG(WARNING) << "Viewport is not ready"; |
| 76 return false; |
| 77 } |
| 78 return point.x >= 0 && point.y >= 0 && point.x < desktop_size_.x && |
| 79 point.y < desktop_size_.y; |
| 80 } |
| 81 |
| 72 ViewMatrix::Point DesktopViewport::ConstrainPointToDesktop( | 82 ViewMatrix::Point DesktopViewport::ConstrainPointToDesktop( |
| 73 const ViewMatrix::Point& point) const { | 83 const ViewMatrix::Point& point) const { |
| 74 if (!IsViewportReady()) { | 84 if (!IsViewportReady()) { |
| 75 LOG(WARNING) << "Cannot constrain point to desktop. Viewport is not ready."; | 85 LOG(WARNING) << "Cannot constrain point to desktop. Viewport is not ready."; |
| 76 return point; | 86 return point; |
| 77 } | 87 } |
| 78 | 88 |
| 79 return ConstrainPointToBounds({0.f, desktop_size_.x, 0.f, desktop_size_.y}, | 89 return ConstrainPointToBounds({0.f, desktop_size_.x, 0.f, desktop_size_.y}, |
| 80 point); | 90 point); |
| 81 } | 91 } |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 | 262 |
| 253 if (new_point.y < bounds.top) { | 263 if (new_point.y < bounds.top) { |
| 254 new_point.y = bounds.top; | 264 new_point.y = bounds.top; |
| 255 } else if (new_point.y > bounds.bottom) { | 265 } else if (new_point.y > bounds.bottom) { |
| 256 new_point.y = bounds.bottom; | 266 new_point.y = bounds.bottom; |
| 257 } | 267 } |
| 258 return new_point; | 268 return new_point; |
| 259 } | 269 } |
| 260 | 270 |
| 261 } // namespace remoting | 271 } // namespace remoting |
| OLD | NEW |