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

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: 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 // Default dots per inch is 96 DPI.
Jamie 2013/03/15 18:33:24 I think the default DPI on Mac is 72, but we ignor
alexeypa (please no reviews) 2013/03/15 20:30:41 Talked to Wez. He said it is better to have this c
11 const int kDefaultDpiX = 96;
12 const int kDefaultDpiY = 96;
13
14 namespace remoting {
15
16 ScreenResolution::ScreenResolution()
17 : dimensions_(SkISize::Make(0, 0)),
18 dpi_(SkIPoint::Make(0, 0)) {
19 }
20
21 ScreenResolution::ScreenResolution(const SkISize& dimensions)
22 : dimensions_(dimensions),
23 dpi_(SkIPoint::Make(0, 0)) {
24 }
25
26 SkIPoint ScreenResolution::GetEffectiveDpi() const {
27 SkIPoint dpi = dpi_;
28 if (!dpi.x())
29 dpi.setX(kDefaultDpiX);
30 if (!dpi.y())
31 dpi.setY(kDefaultDpiY);
32 return dpi;
33 }
34
35 SkISize ScreenResolution::GetLogicalDimensions() const {
36 SkIPoint dpi = GetEffectiveDpi();
37
38 // Make sure there will be no integer overflow while scaling the screen
39 // dimensions.
40 SkISize dimensions = SkISize::Make(
41 std::min(dimensions_.width(),
42 std::numeric_limits<int32_t>::max() / kDefaultDpiX),
43 std::min(dimensions_.height(),
44 std::numeric_limits<int32_t>::max() / kDefaultDpiY));
45
46 // Scale the screen dimensions as if DPI was 96.
47 return SkISize::Make(dimensions.width() * kDefaultDpiX / dpi.x(),
48 dimensions.height() * kDefaultDpiY / dpi.y());
49 }
50
51 bool ScreenResolution::IsNull() const {
52 return !IsValid() || dimensions_.isZero();
53 }
54
55 bool ScreenResolution::IsValid() const {
56 return dimensions_.width() >= 0 && dimensions_.height() >= 0 &&
57 dpi_.x() >= 0 && dpi_.y() >= 0;
58 }
59
60 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698