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

Side by Side Diff: webrtc/modules/desktop_capture/mouse_cursor_monitor_x11.cc

Issue 1743203002: Replace scoped_ptr with unique_ptr in webrtc/modules/desktop_capture/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: More Windows reverts Created 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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
11 #include <memory>
12
11 #include "webrtc/modules/desktop_capture/mouse_cursor_monitor.h" 13 #include "webrtc/modules/desktop_capture/mouse_cursor_monitor.h"
12 14
13 #include <X11/extensions/Xfixes.h> 15 #include <X11/extensions/Xfixes.h>
14 #include <X11/Xlib.h> 16 #include <X11/Xlib.h>
15 #include <X11/Xutil.h> 17 #include <X11/Xutil.h>
16 18
17 #include "webrtc/base/scoped_ptr.h"
18 #include "webrtc/modules/desktop_capture/desktop_capture_options.h" 19 #include "webrtc/modules/desktop_capture/desktop_capture_options.h"
19 #include "webrtc/modules/desktop_capture/desktop_frame.h" 20 #include "webrtc/modules/desktop_capture/desktop_frame.h"
20 #include "webrtc/modules/desktop_capture/mouse_cursor.h" 21 #include "webrtc/modules/desktop_capture/mouse_cursor.h"
21 #include "webrtc/modules/desktop_capture/x11/x_error_trap.h" 22 #include "webrtc/modules/desktop_capture/x11/x_error_trap.h"
22 #include "webrtc/system_wrappers/include/logging.h" 23 #include "webrtc/system_wrappers/include/logging.h"
23 24
24 namespace { 25 namespace {
25 26
26 // WindowCapturer returns window IDs of X11 windows with WM_STATE attribute. 27 // WindowCapturer returns window IDs of X11 windows with WM_STATE attribute.
27 // These windows may not be immediate children of the root window, because 28 // These windows may not be immediate children of the root window, because
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 78
78 rtc::scoped_refptr<SharedXDisplay> x_display_; 79 rtc::scoped_refptr<SharedXDisplay> x_display_;
79 Callback* callback_; 80 Callback* callback_;
80 Mode mode_; 81 Mode mode_;
81 Window window_; 82 Window window_;
82 83
83 bool have_xfixes_; 84 bool have_xfixes_;
84 int xfixes_event_base_; 85 int xfixes_event_base_;
85 int xfixes_error_base_; 86 int xfixes_error_base_;
86 87
87 rtc::scoped_ptr<MouseCursor> cursor_shape_; 88 std::unique_ptr<MouseCursor> cursor_shape_;
88 }; 89 };
89 90
90 MouseCursorMonitorX11::MouseCursorMonitorX11( 91 MouseCursorMonitorX11::MouseCursorMonitorX11(
91 const DesktopCaptureOptions& options, 92 const DesktopCaptureOptions& options,
92 Window window) 93 Window window)
93 : x_display_(options.x_display()), 94 : x_display_(options.x_display()),
94 callback_(NULL), 95 callback_(NULL),
95 mode_(SHAPE_AND_POSITION), 96 mode_(SHAPE_AND_POSITION),
96 window_(window), 97 window_(window),
97 have_xfixes_(false), 98 have_xfixes_(false),
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 assert(have_xfixes_); 184 assert(have_xfixes_);
184 185
185 XFixesCursorImage* img; 186 XFixesCursorImage* img;
186 { 187 {
187 XErrorTrap error_trap(display()); 188 XErrorTrap error_trap(display());
188 img = XFixesGetCursorImage(display()); 189 img = XFixesGetCursorImage(display());
189 if (!img || error_trap.GetLastErrorAndDisable() != 0) 190 if (!img || error_trap.GetLastErrorAndDisable() != 0)
190 return; 191 return;
191 } 192 }
192 193
193 rtc::scoped_ptr<DesktopFrame> image( 194 std::unique_ptr<DesktopFrame> image(
194 new BasicDesktopFrame(DesktopSize(img->width, img->height))); 195 new BasicDesktopFrame(DesktopSize(img->width, img->height)));
195 196
196 // Xlib stores 32-bit data in longs, even if longs are 64-bits long. 197 // Xlib stores 32-bit data in longs, even if longs are 64-bits long.
197 unsigned long* src = img->pixels; 198 unsigned long* src = img->pixels;
198 uint32_t* dst = reinterpret_cast<uint32_t*>(image->data()); 199 uint32_t* dst = reinterpret_cast<uint32_t*>(image->data());
199 uint32_t* dst_end = dst + (img->width * img->height); 200 uint32_t* dst_end = dst + (img->width * img->height);
200 while (dst < dst_end) { 201 while (dst < dst_end) {
201 *dst++ = static_cast<uint32_t>(*src++); 202 *dst++ = static_cast<uint32_t>(*src++);
202 } 203 }
203 204
(...skipping 19 matching lines...) Expand all
223 MouseCursorMonitor* MouseCursorMonitor::CreateForScreen( 224 MouseCursorMonitor* MouseCursorMonitor::CreateForScreen(
224 const DesktopCaptureOptions& options, 225 const DesktopCaptureOptions& options,
225 ScreenId screen) { 226 ScreenId screen) {
226 if (!options.x_display()) 227 if (!options.x_display())
227 return NULL; 228 return NULL;
228 return new MouseCursorMonitorX11( 229 return new MouseCursorMonitorX11(
229 options, DefaultRootWindow(options.x_display()->display())); 230 options, DefaultRootWindow(options.x_display()->display()));
230 } 231 }
231 232
232 } // namespace webrtc 233 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698