Chromium Code Reviews| 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 // Scale the screen dimensions to new DPI. | |
|
Jamie
2013/03/15 22:06:27
DCHECK dpi_ to make sure you're not going to divid
alexeypa (please no reviews)
2013/03/15 22:32:12
It will crash nicely even without a DCHECK(). Why
| |
| 25 int64 width = std::min(dimensions_.width() * new_dpi.x() / dpi_.x(), | |
| 26 std::numeric_limits<int32>::max()); | |
| 27 int64 height = std::min(dimensions_.height() * new_dpi.y() / dpi_.y(), | |
| 28 std::numeric_limits<int32>::max()); | |
| 29 | |
| 30 return SkISize::Make(static_cast<int32>(width), static_cast<int32>(height)); | |
| 31 } | |
| 32 | |
| 33 bool ScreenResolution::IsNull() const { | |
| 34 return dimensions_.isEmpty() || dpi_.x() <= 0 || dpi_.y() <= 0; | |
| 35 } | |
| 36 | |
| 37 bool ScreenResolution::IsValid() const { | |
| 38 return !IsNull() || dimensions_.isZero(); | |
| 39 } | |
| 40 | |
| 41 } // namespace remoting | |
| OLD | NEW |