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

Side by Side Diff: remoting/host/screen_resolution.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
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "remoting/host/screen_resolution.h"
6
7 #include <algorithm>
8 #include <limits>
9
10 namespace remoting {
11
12 ScreenResolution::ScreenResolution()
13 : dimensions_(SkISize::Make(0, 0)),
14 dpi_(SkIPoint::Make(0, 0)) {
15 }
16
17 ScreenResolution::ScreenResolution(const SkISize& dimensions,
18 const SkIPoint& dpi)
19 : dimensions_(dimensions),
20 dpi_(dpi) {
21 }
22
23 SkISize ScreenResolution::ScaleDimensionsToDpi(const SkIPoint& new_dpi) const {
24 int64 width = dimensions_.width();
25 int64 height = dimensions_.height();
26
27 // Scale the screen dimensions to new DPI.
28 width = std::min(width * new_dpi.x() / dpi_.x(),
29 static_cast<int64>(std::numeric_limits<int32>::max()));
30 height = std::min(height * new_dpi.y() / dpi_.y(),
31 static_cast<int64>(std::numeric_limits<int32>::max()));
32 return SkISize::Make(static_cast<int32>(width), static_cast<int32>(height));
33 }
34
35 bool ScreenResolution::IsEmpty() const {
36 return dimensions_.isEmpty() || dpi_.x() <= 0 || dpi_.y() <= 0;
37 }
38
39 bool ScreenResolution::IsValid() const {
40 return !IsEmpty() || dimensions_.isZero();
41 }
42
43 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698