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

Unified Diff: remoting/client/ui/desktop_viewport.cc

Issue 2891603002: [CRD iOS] Trackpad Input Mode (Closed)
Patch Set: Fix 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/client/ui/desktop_viewport.h ('k') | remoting/client/ui/direct_input_strategy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/client/ui/desktop_viewport.cc
diff --git a/remoting/client/ui/desktop_viewport.cc b/remoting/client/ui/desktop_viewport.cc
index e85356563e1b79224c340e859f53f8873e1f42d0..523afbde4150c3285f5cd1c7171d6c5f8f4cde18 100644
--- a/remoting/client/ui/desktop_viewport.cc
+++ b/remoting/client/ui/desktop_viewport.cc
@@ -60,6 +60,26 @@ void DesktopViewport::SetViewportCenter(float x, float y) {
MoveViewport(x - old_center.x, y - old_center.y);
}
+ViewMatrix::Point DesktopViewport::GetViewportCenter() const {
+ if (!IsViewportReady()) {
+ LOG(WARNING) << "Viewport is not ready before getting the viewport center";
+ return {0.f, 0.f};
+ }
+ return desktop_to_surface_transform_.Invert().MapPoint(
+ {surface_size_.x / 2.f, surface_size_.y / 2.f});
+}
+
+ViewMatrix::Point DesktopViewport::ConstrainPointToDesktop(
+ const ViewMatrix::Point& point) const {
+ if (!IsViewportReady()) {
+ LOG(WARNING) << "Cannot constrain point to desktop. Viewport is not ready.";
+ return point;
+ }
+
+ return ConstrainPointToBounds({0.f, desktop_size_.x, 0.f, desktop_size_.y},
+ point);
+}
+
void DesktopViewport::RegisterOnTransformationChangedCallback(
const TransformationCallback& callback,
bool run_immediately) {
@@ -212,11 +232,6 @@ DesktopViewport::Bounds DesktopViewport::GetViewportCenterBounds() const {
return bounds;
}
-ViewMatrix::Point DesktopViewport::GetViewportCenter() const {
- return desktop_to_surface_transform_.Invert().MapPoint(
- {surface_size_.x / 2.f, surface_size_.y / 2.f});
-}
-
void DesktopViewport::MoveViewportWithoutUpdate(float dx, float dy) {
// <dx, dy> is defined on desktop's reference frame. Translation must be
// flipped and scaled.
« no previous file with comments | « remoting/client/ui/desktop_viewport.h ('k') | remoting/client/ui/direct_input_strategy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698