| 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/desktop_viewport.h" | 5 #include "remoting/client/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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 void DesktopViewport::MoveDesktop(float dx, float dy) { | 47 void DesktopViewport::MoveDesktop(float dx, float dy) { |
| 48 desktop_to_surface_transform_.PostTranslate({dx, dy}); | 48 desktop_to_surface_transform_.PostTranslate({dx, dy}); |
| 49 UpdateViewport(); | 49 UpdateViewport(); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void DesktopViewport::ScaleDesktop(float px, float py, float scale) { | 52 void DesktopViewport::ScaleDesktop(float px, float py, float scale) { |
| 53 desktop_to_surface_transform_.PostScale({px, py}, scale); | 53 desktop_to_surface_transform_.PostScale({px, py}, scale); |
| 54 UpdateViewport(); | 54 UpdateViewport(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 void DesktopViewport::MoveViewportCenter(float dx, float dy) { |
| 58 MoveViewportCenterWithoutUpdate(dx, dy); |
| 59 UpdateViewport(); |
| 60 } |
| 61 |
| 57 void DesktopViewport::SetViewportCenter(float x, float y) { | 62 void DesktopViewport::SetViewportCenter(float x, float y) { |
| 58 ViewMatrix::Point old_center = GetViewportCenter(); | 63 ViewMatrix::Point old_center = GetViewportCenter(); |
| 59 MoveViewportCenterWithoutUpdate(x - old_center.x, y - old_center.y); | 64 MoveViewportCenter(x - old_center.x, y - old_center.y); |
| 60 UpdateViewport(); | |
| 61 } | 65 } |
| 62 | 66 |
| 63 void DesktopViewport::RegisterOnTransformationChangedCallback( | 67 void DesktopViewport::RegisterOnTransformationChangedCallback( |
| 64 const TransformationCallback& callback, | 68 const TransformationCallback& callback, |
| 65 bool run_immediately) { | 69 bool run_immediately) { |
| 66 on_transformation_changed_ = callback; | 70 on_transformation_changed_ = callback; |
| 67 if (IsViewportReady() && run_immediately) { | 71 if (IsViewportReady() && run_immediately) { |
| 68 callback.Run(desktop_to_surface_transform_); | 72 callback.Run(desktop_to_surface_transform_); |
| 69 } | 73 } |
| 70 } | 74 } |
| 71 | 75 |
| 76 const ViewMatrix& DesktopViewport::GetTransformation() const { |
| 77 return desktop_to_surface_transform_; |
| 78 } |
| 79 |
| 72 void DesktopViewport::ResizeToFit() { | 80 void DesktopViewport::ResizeToFit() { |
| 73 DCHECK(IsViewportReady()); | 81 DCHECK(IsViewportReady()); |
| 74 | 82 |
| 75 // <---Desktop Width----> | 83 // <---Desktop Width----> |
| 76 // +==========+---------+ | 84 // +==========+---------+ |
| 77 // | | | | 85 // | | | |
| 78 // | Viewport | Desktop | | 86 // | Viewport | Desktop | |
| 79 // | | | | 87 // | | | |
| 80 // +==========+---------+ | 88 // +==========+---------+ |
| 81 // | 89 // |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 | 237 |
| 230 if (new_point.y < bounds.top) { | 238 if (new_point.y < bounds.top) { |
| 231 new_point.y = bounds.top; | 239 new_point.y = bounds.top; |
| 232 } else if (new_point.y > bounds.bottom) { | 240 } else if (new_point.y > bounds.bottom) { |
| 233 new_point.y = bounds.bottom; | 241 new_point.y = bounds.bottom; |
| 234 } | 242 } |
| 235 return new_point; | 243 return new_point; |
| 236 } | 244 } |
| 237 | 245 |
| 238 } // namespace remoting | 246 } // namespace remoting |
| OLD | NEW |