ozone: DCHECK page_flip_request instead of page_flip_request_
[chromium-blink-merge.git] / remoting / host / screen_resolution.cc
blobff3c4777112f445f74d8cc9f69491012e2641f32
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.
5 #include "remoting/host/screen_resolution.h"
7 #include <algorithm>
8 #include <limits>
10 #include "base/logging.h"
12 namespace remoting {
14 ScreenResolution::ScreenResolution()
15 : dimensions_(webrtc::DesktopSize(0, 0)),
16 dpi_(webrtc::DesktopVector(0, 0)) {
19 ScreenResolution::ScreenResolution(const webrtc::DesktopSize& dimensions,
20 const webrtc::DesktopVector& dpi)
21 : dimensions_(dimensions),
22 dpi_(dpi) {
23 // Check that dimensions are not negative.
24 DCHECK(!dimensions.is_empty() || dimensions.equals(webrtc::DesktopSize()));
25 DCHECK_GE(dpi.x(), 0);
26 DCHECK_GE(dpi.y(), 0);
29 webrtc::DesktopSize ScreenResolution::ScaleDimensionsToDpi(
30 const webrtc::DesktopVector& new_dpi) const {
31 int64 width = dimensions_.width();
32 int64 height = dimensions_.height();
34 // Scale the screen dimensions to new DPI.
35 width = std::min(width * new_dpi.x() / dpi_.x(),
36 static_cast<int64>(std::numeric_limits<int32>::max()));
37 height = std::min(height * new_dpi.y() / dpi_.y(),
38 static_cast<int64>(std::numeric_limits<int32>::max()));
39 return webrtc::DesktopSize(width, height);
42 bool ScreenResolution::IsEmpty() const {
43 return dimensions_.is_empty() || dpi_.is_zero();
46 bool ScreenResolution::Equals(const ScreenResolution& other) const {
47 return dimensions_.equals(other.dimensions()) && dpi_.equals(other.dpi());
50 } // namespace remoting