| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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/screen_resolution.h" | 5 #include "remoting/host/screen_resolution.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/logging.h" |
| 11 |
| 10 namespace remoting { | 12 namespace remoting { |
| 11 | 13 |
| 12 ScreenResolution::ScreenResolution() | 14 ScreenResolution::ScreenResolution() |
| 13 : dimensions_(SkISize::Make(0, 0)), | 15 : dimensions_(webrtc::DesktopSize(0, 0)), |
| 14 dpi_(SkIPoint::Make(0, 0)) { | 16 dpi_(webrtc::DesktopVector(0, 0)) { |
| 15 } | 17 } |
| 16 | 18 |
| 17 ScreenResolution::ScreenResolution(const SkISize& dimensions, | 19 ScreenResolution::ScreenResolution(const webrtc::DesktopSize& dimensions, |
| 18 const SkIPoint& dpi) | 20 const webrtc::DesktopVector& dpi) |
| 19 : dimensions_(dimensions), | 21 : dimensions_(dimensions), |
| 20 dpi_(dpi) { | 22 dpi_(dpi) { |
| 23 DCHECK(dimensions.is_empty()); |
| 24 DCHECK_GE(dpi.x(), 0); |
| 25 DCHECK_GE(dpi.y(), 0); |
| 21 } | 26 } |
| 22 | 27 |
| 23 SkISize ScreenResolution::ScaleDimensionsToDpi(const SkIPoint& new_dpi) const { | 28 webrtc::DesktopSize ScreenResolution::ScaleDimensionsToDpi( |
| 29 const webrtc::DesktopVector& new_dpi) const { |
| 24 int64 width = dimensions_.width(); | 30 int64 width = dimensions_.width(); |
| 25 int64 height = dimensions_.height(); | 31 int64 height = dimensions_.height(); |
| 26 | 32 |
| 27 // Scale the screen dimensions to new DPI. | 33 // Scale the screen dimensions to new DPI. |
| 28 width = std::min(width * new_dpi.x() / dpi_.x(), | 34 width = std::min(width * new_dpi.x() / dpi_.x(), |
| 29 static_cast<int64>(std::numeric_limits<int32>::max())); | 35 static_cast<int64>(std::numeric_limits<int32>::max())); |
| 30 height = std::min(height * new_dpi.y() / dpi_.y(), | 36 height = std::min(height * new_dpi.y() / dpi_.y(), |
| 31 static_cast<int64>(std::numeric_limits<int32>::max())); | 37 static_cast<int64>(std::numeric_limits<int32>::max())); |
| 32 return SkISize::Make(static_cast<int32>(width), static_cast<int32>(height)); | 38 return webrtc::DesktopSize(width, height); |
| 33 } | 39 } |
| 34 | 40 |
| 35 bool ScreenResolution::IsEmpty() const { | 41 bool ScreenResolution::IsEmpty() const { |
| 36 return dimensions_.isEmpty() || dpi_.x() <= 0 || dpi_.y() <= 0; | 42 return dimensions_.is_empty() || dpi_.is_zero(); |
| 37 } | |
| 38 | |
| 39 bool ScreenResolution::IsValid() const { | |
| 40 return !IsEmpty() || dimensions_.isZero(); | |
| 41 } | 43 } |
| 42 | 44 |
| 43 } // namespace remoting | 45 } // namespace remoting |
| OLD | NEW |