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

Unified Diff: webrtc/modules/desktop_capture/window_capturer_x11.cc

Issue 1988783003: Use std::unique_ptr<> to pass frame ownership in DesktopCapturer impls. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/modules/desktop_capture/window_capturer_win.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/desktop_capture/window_capturer_x11.cc
diff --git a/webrtc/modules/desktop_capture/window_capturer_x11.cc b/webrtc/modules/desktop_capture/window_capturer_x11.cc
old mode 100755
new mode 100644
index 8ead98109a883ab0ed2b24d17fc5cdc3e1dc4192..d88585bfa8052d34a0de60b58a8089d6a3992bca
--- a/webrtc/modules/desktop_capture/window_capturer_x11.cc
+++ b/webrtc/modules/desktop_capture/window_capturer_x11.cc
@@ -36,10 +36,7 @@ namespace {
template <class PropertyType>
class XWindowProperty {
public:
- XWindowProperty(Display* display, Window window, Atom property)
- : is_valid_(false),
- size_(0),
- data_(NULL) {
+ XWindowProperty(Display* display, Window window, Atom property) {
const int kBitsPerByte = 8;
Atom actual_type;
int actual_format;
@@ -49,7 +46,7 @@ class XWindowProperty {
&actual_format, &size_,
&bytes_after, &data_);
if (status != Success) {
- data_ = NULL;
+ data_ = nullptr;
return;
}
if (sizeof(PropertyType) * kBitsPerByte != actual_format) {
@@ -78,9 +75,9 @@ class XWindowProperty {
}
private:
- bool is_valid_;
- unsigned long size_; // NOLINT: type required by XGetWindowProperty
- unsigned char* data_;
+ bool is_valid_ = false;
+ unsigned long size_ = 0; // NOLINT: type required by XGetWindowProperty
+ unsigned char* data_ = nullptr;
RTC_DISALLOW_COPY_AND_ASSIGN(XWindowProperty);
};
@@ -117,26 +114,23 @@ class WindowCapturerLinux : public WindowCapturer,
// Returns window title for the specified X |window|.
bool GetWindowTitle(::Window window, std::string* title);
- Callback* callback_;
+ Callback* callback_ = nullptr;
rtc::scoped_refptr<SharedXDisplay> x_display_;
Atom wm_state_atom_;
Atom window_type_atom_;
Atom normal_window_type_atom_;
- bool has_composite_extension_;
+ bool has_composite_extension_ = false;
- ::Window selected_window_;
+ ::Window selected_window_ = 0;
XServerPixelBuffer x_server_pixel_buffer_;
RTC_DISALLOW_COPY_AND_ASSIGN(WindowCapturerLinux);
};
WindowCapturerLinux::WindowCapturerLinux(const DesktopCaptureOptions& options)
- : callback_(NULL),
- x_display_(options.x_display()),
- has_composite_extension_(false),
- selected_window_(0) {
+ : x_display_(options.x_display()) {
// Create Atoms so we don't need to do it every time they are used.
wm_state_atom_ = XInternAtom(display(), "WM_STATE", True);
window_type_atom_ = XInternAtom(display(), "_NET_WM_WINDOW_TYPE", True);
@@ -280,7 +274,7 @@ void WindowCapturerLinux::Start(Callback* callback) {
void WindowCapturerLinux::Capture(const DesktopRegion& region) {
if (!x_server_pixel_buffer_.IsWindowValid()) {
LOG(LS_INFO) << "The window is no longer valid.";
- callback_->OnCaptureCompleted(NULL);
+ callback_->OnCaptureResult(Result::ERROR_PERMANENT, nullptr);
return;
}
@@ -291,21 +285,21 @@ void WindowCapturerLinux::Capture(const DesktopRegion& region) {
// visible on screen and not covered by any other window. This is not
// something we want so instead, just bail out.
LOG(LS_INFO) << "No Xcomposite extension detected.";
- callback_->OnCaptureCompleted(NULL);
+ callback_->OnCaptureResult(Result::ERROR_PERMANENT, nullptr);
return;
}
- DesktopFrame* frame =
- new BasicDesktopFrame(x_server_pixel_buffer_.window_size());
+ std::unique_ptr<DesktopFrame> frame(
+ new BasicDesktopFrame(x_server_pixel_buffer_.window_size()));
x_server_pixel_buffer_.Synchronize();
x_server_pixel_buffer_.CaptureRect(DesktopRect::MakeSize(frame->size()),
- frame);
+ frame.get());
frame->mutable_updated_region()->SetRect(
DesktopRect::MakeSize(frame->size()));
- callback_->OnCaptureCompleted(frame);
+ callback_->OnCaptureResult(Result::SUCCESS, std::move(frame));
}
bool WindowCapturerLinux::HandleXEvent(const XEvent& event) {
@@ -399,12 +393,12 @@ bool WindowCapturerLinux::GetWindowTitle(::Window window, std::string* title) {
int status;
bool result = false;
XTextProperty window_name;
- window_name.value = NULL;
+ window_name.value = nullptr;
if (window) {
status = XGetWMName(display(), window, &window_name);
if (status && window_name.value && window_name.nitems) {
int cnt;
- char **list = NULL;
+ char** list = nullptr;
status = Xutf8TextPropertyToTextList(display(), &window_name, &list,
&cnt);
if (status >= Success && cnt && *list) {
@@ -429,7 +423,7 @@ bool WindowCapturerLinux::GetWindowTitle(::Window window, std::string* title) {
// static
WindowCapturer* WindowCapturer::Create(const DesktopCaptureOptions& options) {
if (!options.x_display())
- return NULL;
+ return nullptr;
return new WindowCapturerLinux(options);
}
« no previous file with comments | « webrtc/modules/desktop_capture/window_capturer_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698