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

Unified Diff: remoting/client/desktop_viewport.cc

Issue 2866843002: [Remoting Client] Always ResizeToFit when desktop/surface size is changed (Closed)
Patch Set: Resolve Feedback 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/desktop_viewport.h ('k') | remoting/client/view_matrix.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/client/desktop_viewport.cc
diff --git a/remoting/client/desktop_viewport.cc b/remoting/client/desktop_viewport.cc
index f1b3dda978bd0dc1910ea90a3914b3fca7392fad..dc8b99dc4a06f50b765d73817cb6740535713518 100644
--- a/remoting/client/desktop_viewport.cc
+++ b/remoting/client/desktop_viewport.cc
@@ -21,27 +21,15 @@ DesktopViewport::DesktopViewport() : desktop_to_surface_transform_() {}
DesktopViewport::~DesktopViewport() {}
void DesktopViewport::SetDesktopSize(int desktop_width, int desktop_height) {
- bool need_resize_to_fit = !desktop_size_ready_ && surface_size_ready_;
desktop_size_.x = desktop_width;
desktop_size_.y = desktop_height;
- desktop_size_ready_ = true;
- if (need_resize_to_fit) {
- ResizeToFit();
- } else if (IsViewportReady()) {
- UpdateViewport();
- }
+ ResizeToFit();
}
void DesktopViewport::SetSurfaceSize(int surface_width, int surface_height) {
- bool need_resize_to_fit = desktop_size_ready_ && !surface_size_ready_;
surface_size_.x = surface_width;
surface_size_.y = surface_height;
- surface_size_ready_ = true;
- if (need_resize_to_fit) {
- ResizeToFit();
- } else if (IsViewportReady()) {
- UpdateViewport();
- }
+ ResizeToFit();
}
void DesktopViewport::MoveDesktop(float dx, float dy) {
@@ -70,7 +58,9 @@ void DesktopViewport::RegisterOnTransformationChangedCallback(
}
void DesktopViewport::ResizeToFit() {
- DCHECK(IsViewportReady());
+ if (!IsViewportReady()) {
+ return;
+ }
// <---Desktop Width---->
// +==========+---------+
@@ -93,11 +83,13 @@ void DesktopViewport::ResizeToFit() {
float scale = std::max(surface_size_.x / desktop_size_.x,
surface_size_.y / desktop_size_.y);
desktop_to_surface_transform_.SetScale(scale);
+ desktop_to_surface_transform_.SetOffset({0.f, 0.f});
UpdateViewport();
}
bool DesktopViewport::IsViewportReady() const {
- return desktop_size_ready_ && surface_size_ready_;
+ return desktop_size_.x != 0 && desktop_size_.y != 0 && surface_size_.x != 0 &&
+ surface_size_.y != 0;
}
void DesktopViewport::UpdateViewport() {
« no previous file with comments | « remoting/client/desktop_viewport.h ('k') | remoting/client/view_matrix.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698