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

Side by Side Diff: remoting/host/screen_resolution.cc

Issue 13983010: Use webrtc::DesktopCapturer for screen capturer implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/host/screen_resolution.h ('k') | remoting/host/screen_resolution_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // 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);
21 } 27 }
22 28
23 SkISize ScreenResolution::ScaleDimensionsToDpi(const SkIPoint& new_dpi) const { 29 webrtc::DesktopSize ScreenResolution::ScaleDimensionsToDpi(
30 const webrtc::DesktopVector& new_dpi) const {
24 int64 width = dimensions_.width(); 31 int64 width = dimensions_.width();
25 int64 height = dimensions_.height(); 32 int64 height = dimensions_.height();
26 33
27 // Scale the screen dimensions to new DPI. 34 // Scale the screen dimensions to new DPI.
28 width = std::min(width * new_dpi.x() / dpi_.x(), 35 width = std::min(width * new_dpi.x() / dpi_.x(),
29 static_cast<int64>(std::numeric_limits<int32>::max())); 36 static_cast<int64>(std::numeric_limits<int32>::max()));
30 height = std::min(height * new_dpi.y() / dpi_.y(), 37 height = std::min(height * new_dpi.y() / dpi_.y(),
31 static_cast<int64>(std::numeric_limits<int32>::max())); 38 static_cast<int64>(std::numeric_limits<int32>::max()));
32 return SkISize::Make(static_cast<int32>(width), static_cast<int32>(height)); 39 return webrtc::DesktopSize(width, height);
33 } 40 }
34 41
35 bool ScreenResolution::IsEmpty() const { 42 bool ScreenResolution::IsEmpty() const {
36 return dimensions_.isEmpty() || dpi_.x() <= 0 || dpi_.y() <= 0; 43 return dimensions_.is_empty() || dpi_.is_zero();
37 }
38
39 bool ScreenResolution::IsValid() const {
40 return !IsEmpty() || dimensions_.isZero();
41 } 44 }
42 45
43 } // namespace remoting 46 } // namespace remoting
OLDNEW
« 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