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

Unified 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: CR feedback 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/screen_resolution.h ('k') | remoting/host/screen_resolution_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/screen_resolution.cc
diff --git a/remoting/host/screen_resolution.cc b/remoting/host/screen_resolution.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a8a7e682155d4cd44e6dedbc860d0c87f0cd72fa
--- /dev/null
+++ b/remoting/host/screen_resolution.cc
@@ -0,0 +1,43 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/host/screen_resolution.h"
+
+#include <algorithm>
+#include <limits>
+
+namespace remoting {
+
+ScreenResolution::ScreenResolution()
+ : dimensions_(SkISize::Make(0, 0)),
+ dpi_(SkIPoint::Make(0, 0)) {
+}
+
+ScreenResolution::ScreenResolution(const SkISize& dimensions,
+ const SkIPoint& dpi)
+ : dimensions_(dimensions),
+ dpi_(dpi) {
+}
+
+SkISize ScreenResolution::ScaleDimensionsToDpi(const SkIPoint& new_dpi) const {
+ int64 width = dimensions_.width();
+ int64 height = dimensions_.height();
+
+ // Scale the screen dimensions to new DPI.
+ width = std::min(width * new_dpi.x() / dpi_.x(),
+ static_cast<int64>(std::numeric_limits<int32>::max()));
+ height = std::min(height * new_dpi.y() / dpi_.y(),
+ static_cast<int64>(std::numeric_limits<int32>::max()));
+ return SkISize::Make(static_cast<int32>(width), static_cast<int32>(height));
+}
+
+bool ScreenResolution::IsEmpty() const {
+ return dimensions_.isEmpty() || dpi_.x() <= 0 || dpi_.y() <= 0;
+}
+
+bool ScreenResolution::IsValid() const {
+ return !IsEmpty() || dimensions_.isZero();
+}
+
+} // namespace remoting
« no previous file with comments | « remoting/host/screen_resolution.h ('k') | remoting/host/screen_resolution_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698