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

Side by Side Diff: remoting/host/resizing_host_observer.cc

Issue 12678008: Reworked the plumbing required to pass the client resolution to the desktop resizer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR feedback. Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/host/resizing_host_observer.h" 5 #include "remoting/host/resizing_host_observer.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "remoting/host/desktop_resizer.h" 10 #include "remoting/host/desktop_resizer.h"
11 #include "remoting/host/screen_resolution.h"
11 12
12 namespace { 13 namespace {
13 14
14 class CandidateSize { 15 class CandidateSize {
15 public: 16 public:
16 CandidateSize(const SkISize& candidate, const SkISize& preferred) 17 CandidateSize(const SkISize& candidate, const SkISize& preferred)
17 : size_(candidate) { 18 : size_(candidate) {
18 // Protect against division by zero. 19 // Protect against division by zero.
19 CHECK(!candidate.isEmpty()); 20 CHECK(!candidate.isEmpty());
20 DCHECK(!preferred.isEmpty()); 21 DCHECK(!preferred.isEmpty());
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 scoped_ptr<DesktopResizer> desktop_resizer) 102 scoped_ptr<DesktopResizer> desktop_resizer)
102 : desktop_resizer_(desktop_resizer.Pass()), 103 : desktop_resizer_(desktop_resizer.Pass()),
103 original_size_(desktop_resizer_->GetCurrentSize()) { 104 original_size_(desktop_resizer_->GetCurrentSize()) {
104 } 105 }
105 106
106 ResizingHostObserver::~ResizingHostObserver() { 107 ResizingHostObserver::~ResizingHostObserver() {
107 if (!original_size_.isZero()) 108 if (!original_size_.isZero())
108 desktop_resizer_->RestoreSize(original_size_); 109 desktop_resizer_->RestoreSize(original_size_);
109 } 110 }
110 111
111 void ResizingHostObserver::OnClientResolutionChanged( 112 void ResizingHostObserver::SetScreenResolution(
112 const SkIPoint& client_dpi, 113 const ScreenResolution& resolution) {
113 const SkISize& client_size) { 114 if (resolution.IsEmpty())
114 if (client_size.isEmpty()) {
115 return; 115 return;
116 }
117 116
118 // If the implementation returns any sizes, pick the best one according to 117 // If the implementation returns any sizes, pick the best one according to
119 // the algorithm described in CandidateSize::IsBetterThen. 118 // the algorithm described in CandidateSize::IsBetterThen.
120 std::list<SkISize> sizes = 119 std::list<SkISize> sizes =
121 desktop_resizer_->GetSupportedSizes(client_size); 120 desktop_resizer_->GetSupportedSizes(resolution.dimensions_);
122 if (sizes.empty()) { 121 if (sizes.empty()) {
123 return; 122 return;
124 } 123 }
125 CandidateSize best_size(sizes.front(), client_size); 124 CandidateSize best_size(sizes.front(), resolution.dimensions_);
126 for (std::list<SkISize>::const_iterator i = ++sizes.begin(); 125 for (std::list<SkISize>::const_iterator i = ++sizes.begin();
127 i != sizes.end(); ++i) { 126 i != sizes.end(); ++i) {
128 CandidateSize candidate_size(*i, client_size); 127 CandidateSize candidate_size(*i, resolution.dimensions_);
129 if (candidate_size.IsBetterThan(best_size)) { 128 if (candidate_size.IsBetterThan(best_size)) {
130 best_size = candidate_size; 129 best_size = candidate_size;
131 } 130 }
132 } 131 }
133 SkISize current_size = desktop_resizer_->GetCurrentSize(); 132 SkISize current_size = desktop_resizer_->GetCurrentSize();
134 if (best_size.size() != current_size) 133 if (best_size.size() != current_size)
135 desktop_resizer_->SetSize(best_size.size()); 134 desktop_resizer_->SetSize(best_size.size());
136 } 135 }
137 136
138 } // namespace remoting 137 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698