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

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

Issue 810133003: replace NULL->nullptr in src/remoting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « remoting/host/desktop_resizer_linux.cc ('k') | remoting/host/desktop_resizer_win.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) 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 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/mac/foundation_util.h" 10 #include "base/mac/foundation_util.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 if (base::mac::IsOSSnowLeopard() || !GetSoleDisplayId(&display)) { 68 if (base::mac::IsOSSnowLeopard() || !GetSoleDisplayId(&display)) {
69 return; 69 return;
70 } 70 }
71 71
72 base::ScopedCFTypeRef<CFMutableArrayRef> modes; 72 base::ScopedCFTypeRef<CFMutableArrayRef> modes;
73 std::list<ScreenResolution> resolutions; 73 std::list<ScreenResolution> resolutions;
74 GetSupportedModesAndResolutions(&modes, &resolutions); 74 GetSupportedModesAndResolutions(&modes, &resolutions);
75 // There may be many modes with the requested resolution. Pick the one with 75 // There may be many modes with the requested resolution. Pick the one with
76 // the highest color depth. 76 // the highest color depth.
77 int index = 0, best_depth = 0; 77 int index = 0, best_depth = 0;
78 CGDisplayModeRef best_mode = NULL; 78 CGDisplayModeRef best_mode = nullptr;
79 for (std::list<ScreenResolution>::const_iterator i = resolutions.begin(); 79 for (std::list<ScreenResolution>::const_iterator i = resolutions.begin();
80 i != resolutions.end(); ++i, ++index) { 80 i != resolutions.end(); ++i, ++index) {
81 if (i->Equals(resolution)) { 81 if (i->Equals(resolution)) {
82 CGDisplayModeRef mode = const_cast<CGDisplayModeRef>( 82 CGDisplayModeRef mode = const_cast<CGDisplayModeRef>(
83 static_cast<const CGDisplayMode*>( 83 static_cast<const CGDisplayMode*>(
84 CFArrayGetValueAtIndex(modes, index))); 84 CFArrayGetValueAtIndex(modes, index)));
85 int depth = 0; 85 int depth = 0;
86 base::ScopedCFTypeRef<CFStringRef> encoding( 86 base::ScopedCFTypeRef<CFStringRef> encoding(
87 CGDisplayModeCopyPixelEncoding(mode)); 87 CGDisplayModeCopyPixelEncoding(mode));
88 if (CFStringCompare(encoding, CFSTR(IO32BitDirectPixels), 88 if (CFStringCompare(encoding, CFSTR(IO32BitDirectPixels),
(...skipping 13 matching lines...) Expand all
102 best_mode = mode; 102 best_mode = mode;
103 } 103 }
104 } 104 }
105 } 105 }
106 if (best_mode) { 106 if (best_mode) {
107 HOST_LOG << "Changing mode to " << best_mode << " (" 107 HOST_LOG << "Changing mode to " << best_mode << " ("
108 << resolution.dimensions().width() << "x" 108 << resolution.dimensions().width() << "x"
109 << "x" << resolution.dimensions().height() << "x" 109 << "x" << resolution.dimensions().height() << "x"
110 << best_depth << " @ " 110 << best_depth << " @ "
111 << resolution.dpi().x() << "x" << resolution.dpi().y() << " dpi)"; 111 << resolution.dpi().x() << "x" << resolution.dpi().y() << " dpi)";
112 CGDisplaySetDisplayMode(display, best_mode, NULL); 112 CGDisplaySetDisplayMode(display, best_mode, nullptr);
113 } 113 }
114 } 114 }
115 115
116 void DesktopResizerMac::RestoreResolution(const ScreenResolution& original) { 116 void DesktopResizerMac::RestoreResolution(const ScreenResolution& original) {
117 SetResolution(original); 117 SetResolution(original);
118 } 118 }
119 119
120 void DesktopResizerMac::GetSupportedModesAndResolutions( 120 void DesktopResizerMac::GetSupportedModesAndResolutions(
121 base::ScopedCFTypeRef<CFMutableArrayRef>* modes, 121 base::ScopedCFTypeRef<CFMutableArrayRef>* modes,
122 std::list<ScreenResolution>* resolutions) { 122 std::list<ScreenResolution>* resolutions) {
123 CGDirectDisplayID display; 123 CGDirectDisplayID display;
124 if (!GetSoleDisplayId(&display)) { 124 if (!GetSoleDisplayId(&display)) {
125 return; 125 return;
126 } 126 }
127 127
128 base::ScopedCFTypeRef<CFArrayRef> all_modes( 128 base::ScopedCFTypeRef<CFArrayRef> all_modes(
129 CGDisplayCopyAllDisplayModes(display, NULL)); 129 CGDisplayCopyAllDisplayModes(display, nullptr));
130 if (!all_modes) { 130 if (!all_modes) {
131 return; 131 return;
132 } 132 }
133 133
134 modes->reset(CFArrayCreateMutableCopy(NULL, 0, all_modes)); 134 modes->reset(CFArrayCreateMutableCopy(nullptr, 0, all_modes));
135 CFIndex count = CFArrayGetCount(*modes); 135 CFIndex count = CFArrayGetCount(*modes);
136 for (CFIndex i = 0; i < count; ++i) { 136 for (CFIndex i = 0; i < count; ++i) {
137 CGDisplayModeRef mode = const_cast<CGDisplayModeRef>( 137 CGDisplayModeRef mode = const_cast<CGDisplayModeRef>(
138 static_cast<const CGDisplayMode*>( 138 static_cast<const CGDisplayMode*>(
139 CFArrayGetValueAtIndex(*modes, i))); 139 CFArrayGetValueAtIndex(*modes, i)));
140 if (CGDisplayModeIsUsableForDesktopGUI(mode)) { 140 if (CGDisplayModeIsUsableForDesktopGUI(mode)) {
141 // TODO(jamiewalch): Get the correct DPI: http://crbug.com/172405. 141 // TODO(jamiewalch): Get the correct DPI: http://crbug.com/172405.
142 ScreenResolution resolution( 142 ScreenResolution resolution(
143 webrtc::DesktopSize(CGDisplayModeGetWidth(mode), 143 webrtc::DesktopSize(CGDisplayModeGetWidth(mode),
144 CGDisplayModeGetHeight(mode)), 144 CGDisplayModeGetHeight(mode)),
(...skipping 19 matching lines...) Expand all
164 } 164 }
165 *display = displays[0]; 165 *display = displays[0];
166 return true; 166 return true;
167 } 167 }
168 168
169 scoped_ptr<DesktopResizer> DesktopResizer::Create() { 169 scoped_ptr<DesktopResizer> DesktopResizer::Create() {
170 return make_scoped_ptr(new DesktopResizerMac); 170 return make_scoped_ptr(new DesktopResizerMac);
171 } 171 }
172 172
173 } // namespace remoting 173 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/desktop_resizer_linux.cc ('k') | remoting/host/desktop_resizer_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698