OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/desktop_resizer.h" | 5 #include "remoting/host/desktop_resizer.h" |
6 | 6 |
7 #include <Carbon/Carbon.h> | 7 #include <Carbon/Carbon.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 base::ScopedCFTypeRef<CFMutableArrayRef>* modes, | 40 base::ScopedCFTypeRef<CFMutableArrayRef>* modes, |
41 std::list<ScreenResolution>* resolutions); | 41 std::list<ScreenResolution>* resolutions); |
42 | 42 |
43 DISALLOW_COPY_AND_ASSIGN(DesktopResizerMac); | 43 DISALLOW_COPY_AND_ASSIGN(DesktopResizerMac); |
44 }; | 44 }; |
45 | 45 |
46 DesktopResizerMac::DesktopResizerMac() {} | 46 DesktopResizerMac::DesktopResizerMac() {} |
47 | 47 |
48 ScreenResolution DesktopResizerMac::GetCurrentResolution() { | 48 ScreenResolution DesktopResizerMac::GetCurrentResolution() { |
49 CGDirectDisplayID display; | 49 CGDirectDisplayID display; |
50 if (!base::mac::IsOSSnowLeopard() && GetSoleDisplayId(&display)) { | 50 if (GetSoleDisplayId(&display)) { |
51 CGRect rect = CGDisplayBounds(display); | 51 CGRect rect = CGDisplayBounds(display); |
52 return ScreenResolution( | 52 return ScreenResolution( |
53 webrtc::DesktopSize(rect.size.width, rect.size.height), | 53 webrtc::DesktopSize(rect.size.width, rect.size.height), |
54 webrtc::DesktopVector(kDefaultDPI, kDefaultDPI)); | 54 webrtc::DesktopVector(kDefaultDPI, kDefaultDPI)); |
55 } | 55 } |
56 return ScreenResolution(); | 56 return ScreenResolution(); |
57 } | 57 } |
58 | 58 |
59 std::list<ScreenResolution> DesktopResizerMac::GetSupportedResolutions( | 59 std::list<ScreenResolution> DesktopResizerMac::GetSupportedResolutions( |
60 const ScreenResolution& preferred) { | 60 const ScreenResolution& preferred) { |
61 base::ScopedCFTypeRef<CFMutableArrayRef> modes; | 61 base::ScopedCFTypeRef<CFMutableArrayRef> modes; |
62 std::list<ScreenResolution> resolutions; | 62 std::list<ScreenResolution> resolutions; |
63 GetSupportedModesAndResolutions(&modes, &resolutions); | 63 GetSupportedModesAndResolutions(&modes, &resolutions); |
64 return resolutions; | 64 return resolutions; |
65 } | 65 } |
66 | 66 |
67 void DesktopResizerMac::SetResolution(const ScreenResolution& resolution) { | 67 void DesktopResizerMac::SetResolution(const ScreenResolution& resolution) { |
68 CGDirectDisplayID display; | 68 CGDirectDisplayID display; |
69 if (base::mac::IsOSSnowLeopard() || !GetSoleDisplayId(&display)) { | 69 if (!GetSoleDisplayId(&display)) { |
70 return; | 70 return; |
71 } | 71 } |
72 | 72 |
73 base::ScopedCFTypeRef<CFMutableArrayRef> modes; | 73 base::ScopedCFTypeRef<CFMutableArrayRef> modes; |
74 std::list<ScreenResolution> resolutions; | 74 std::list<ScreenResolution> resolutions; |
75 GetSupportedModesAndResolutions(&modes, &resolutions); | 75 GetSupportedModesAndResolutions(&modes, &resolutions); |
76 // There may be many modes with the requested resolution. Pick the one with | 76 // There may be many modes with the requested resolution. Pick the one with |
77 // the highest color depth. | 77 // the highest color depth. |
78 int index = 0, best_depth = 0; | 78 int index = 0, best_depth = 0; |
79 CGDisplayModeRef best_mode = nullptr; | 79 CGDisplayModeRef best_mode = nullptr; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 } | 165 } |
166 *display = displays[0]; | 166 *display = displays[0]; |
167 return true; | 167 return true; |
168 } | 168 } |
169 | 169 |
170 scoped_ptr<DesktopResizer> DesktopResizer::Create() { | 170 scoped_ptr<DesktopResizer> DesktopResizer::Create() { |
171 return make_scoped_ptr(new DesktopResizerMac); | 171 return make_scoped_ptr(new DesktopResizerMac); |
172 } | 172 } |
173 | 173 |
174 } // namespace remoting | 174 } // namespace remoting |
OLD | NEW |