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

Side by Side Diff: webrtc/modules/desktop_capture/win/screen_capturer_win_gdi.cc

Issue 2685783014: Replace NULL with nullptr in all C++ files. (Closed)
Patch Set: Fixing android. Created 3 years, 10 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 if (dwmapi_library_) { 47 if (dwmapi_library_) {
48 composition_func_ = reinterpret_cast<DwmEnableCompositionFunc>( 48 composition_func_ = reinterpret_cast<DwmEnableCompositionFunc>(
49 GetProcAddress(dwmapi_library_, "DwmEnableComposition")); 49 GetProcAddress(dwmapi_library_, "DwmEnableComposition"));
50 } 50 }
51 } 51 }
52 } 52 }
53 53
54 ScreenCapturerWinGdi::~ScreenCapturerWinGdi() { 54 ScreenCapturerWinGdi::~ScreenCapturerWinGdi() {
55 if (desktop_dc_) 55 if (desktop_dc_)
56 ReleaseDC(NULL, desktop_dc_); 56 ReleaseDC(nullptr, desktop_dc_);
57 if (memory_dc_) 57 if (memory_dc_)
58 DeleteDC(memory_dc_); 58 DeleteDC(memory_dc_);
59 59
60 // Restore Aero. 60 // Restore Aero.
61 if (composition_func_) 61 if (composition_func_)
62 (*composition_func_)(DWM_EC_ENABLECOMPOSITION); 62 (*composition_func_)(DWM_EC_ENABLECOMPOSITION);
63 63
64 if (dwmapi_library_) 64 if (dwmapi_library_)
65 FreeLibrary(dwmapi_library_); 65 FreeLibrary(dwmapi_library_);
66 } 66 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 (*composition_func_)(DWM_EC_DISABLECOMPOSITION); 121 (*composition_func_)(DWM_EC_DISABLECOMPOSITION);
122 } 122 }
123 123
124 void ScreenCapturerWinGdi::PrepareCaptureResources() { 124 void ScreenCapturerWinGdi::PrepareCaptureResources() {
125 // Switch to the desktop receiving user input if different from the current 125 // Switch to the desktop receiving user input if different from the current
126 // one. 126 // one.
127 std::unique_ptr<Desktop> input_desktop(Desktop::GetInputDesktop()); 127 std::unique_ptr<Desktop> input_desktop(Desktop::GetInputDesktop());
128 if (input_desktop && !desktop_.IsSame(*input_desktop)) { 128 if (input_desktop && !desktop_.IsSame(*input_desktop)) {
129 // Release GDI resources otherwise SetThreadDesktop will fail. 129 // Release GDI resources otherwise SetThreadDesktop will fail.
130 if (desktop_dc_) { 130 if (desktop_dc_) {
131 ReleaseDC(NULL, desktop_dc_); 131 ReleaseDC(nullptr, desktop_dc_);
132 desktop_dc_ = nullptr; 132 desktop_dc_ = nullptr;
133 } 133 }
134 134
135 if (memory_dc_) { 135 if (memory_dc_) {
136 DeleteDC(memory_dc_); 136 DeleteDC(memory_dc_);
137 memory_dc_ = nullptr; 137 memory_dc_ = nullptr;
138 } 138 }
139 139
140 // If SetThreadDesktop() fails, the thread is still assigned a desktop. 140 // If SetThreadDesktop() fails, the thread is still assigned a desktop.
141 // So we can continue capture screen bits, just from the wrong desktop. 141 // So we can continue capture screen bits, just from the wrong desktop.
142 desktop_.SetThreadDesktop(input_desktop.release()); 142 desktop_.SetThreadDesktop(input_desktop.release());
143 143
144 // Re-assert our vote to disable Aero. 144 // Re-assert our vote to disable Aero.
145 // See crbug.com/124018 and crbug.com/129906. 145 // See crbug.com/124018 and crbug.com/129906.
146 if (composition_func_) { 146 if (composition_func_) {
147 (*composition_func_)(DWM_EC_DISABLECOMPOSITION); 147 (*composition_func_)(DWM_EC_DISABLECOMPOSITION);
148 } 148 }
149 } 149 }
150 150
151 // If the display bounds have changed then recreate GDI resources. 151 // If the display bounds have changed then recreate GDI resources.
152 // TODO(wez): Also check for pixel format changes. 152 // TODO(wez): Also check for pixel format changes.
153 DesktopRect screen_rect(DesktopRect::MakeXYWH( 153 DesktopRect screen_rect(DesktopRect::MakeXYWH(
154 GetSystemMetrics(SM_XVIRTUALSCREEN), 154 GetSystemMetrics(SM_XVIRTUALSCREEN),
155 GetSystemMetrics(SM_YVIRTUALSCREEN), 155 GetSystemMetrics(SM_YVIRTUALSCREEN),
156 GetSystemMetrics(SM_CXVIRTUALSCREEN), 156 GetSystemMetrics(SM_CXVIRTUALSCREEN),
157 GetSystemMetrics(SM_CYVIRTUALSCREEN))); 157 GetSystemMetrics(SM_CYVIRTUALSCREEN)));
158 if (!screen_rect.equals(desktop_dc_rect_)) { 158 if (!screen_rect.equals(desktop_dc_rect_)) {
159 if (desktop_dc_) { 159 if (desktop_dc_) {
160 ReleaseDC(NULL, desktop_dc_); 160 ReleaseDC(nullptr, desktop_dc_);
161 desktop_dc_ = nullptr; 161 desktop_dc_ = nullptr;
162 } 162 }
163 if (memory_dc_) { 163 if (memory_dc_) {
164 DeleteDC(memory_dc_); 164 DeleteDC(memory_dc_);
165 memory_dc_ = nullptr; 165 memory_dc_ = nullptr;
166 } 166 }
167 desktop_dc_rect_ = DesktopRect(); 167 desktop_dc_rect_ = DesktopRect();
168 } 168 }
169 169
170 if (!desktop_dc_) { 170 if (!desktop_dc_) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 } 222 }
223 223
224 // Select back the previously selected object to that the device contect 224 // Select back the previously selected object to that the device contect
225 // could be destroyed independently of the bitmap if needed. 225 // could be destroyed independently of the bitmap if needed.
226 SelectObject(memory_dc_, previous_object); 226 SelectObject(memory_dc_, previous_object);
227 227
228 return result; 228 return result;
229 } 229 }
230 230
231 } // namespace webrtc 231 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698