| OLD | NEW |
| (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 |
| OLD | NEW |