From 6d7b8359b3ecad79b4d5ffcd82a48e3571f45bab Mon Sep 17 00:00:00 2001 From: Julien Isorce Date: Tue, 27 Mar 2018 10:09:28 +0100 Subject: [PATCH] Some minor cleanups in ScreenCapturerMac - Remove unsued ScopedPixelBufferObject that was used for the capture using OpenGL. - Also remove InvertedDesktopFrame for the same reason. - Replace several occurrences of assert by RTC_DCHECK Bug: webrtc:8652 Change-Id: I262db0a445f2211cde7476a6cadfb1c19a3e814f Reviewed-on: https://webrtc-review.googlesource.com/64883 Commit-Queue: Zijie He Reviewed-by: Zijie He Cr-Commit-Position: refs/heads/master@{#22632} --- modules/desktop_capture/BUILD.gn | 3 - .../mac/scoped_pixel_buffer_object.cc | 55 ------------------- .../mac/scoped_pixel_buffer_object.h | 41 -------------- .../desktop_capture/mac/screen_capturer_mac.h | 3 - .../mac/screen_capturer_mac.mm | 38 ++----------- 5 files changed, 5 insertions(+), 135 deletions(-) delete mode 100644 modules/desktop_capture/mac/scoped_pixel_buffer_object.cc delete mode 100644 modules/desktop_capture/mac/scoped_pixel_buffer_object.h diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn index 6a10b56ebc..6f116daa9f 100644 --- a/modules/desktop_capture/BUILD.gn +++ b/modules/desktop_capture/BUILD.gn @@ -194,7 +194,6 @@ if (is_mac) { libs = [ "AppKit.framework", "IOKit.framework", - "OpenGL.framework", ] } } @@ -241,8 +240,6 @@ rtc_static_library("desktop_capture_generic") { "mac/desktop_configuration_monitor.h", "mac/full_screen_chrome_window_detector.cc", "mac/full_screen_chrome_window_detector.h", - "mac/scoped_pixel_buffer_object.cc", - "mac/scoped_pixel_buffer_object.h", "mac/window_list_utils.cc", "mac/window_list_utils.h", "mouse_cursor.cc", diff --git a/modules/desktop_capture/mac/scoped_pixel_buffer_object.cc b/modules/desktop_capture/mac/scoped_pixel_buffer_object.cc deleted file mode 100644 index 7ba12d757f..0000000000 --- a/modules/desktop_capture/mac/scoped_pixel_buffer_object.cc +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "modules/desktop_capture/mac/scoped_pixel_buffer_object.h" - -#include - -namespace webrtc { - -ScopedPixelBufferObject::ScopedPixelBufferObject() - : cgl_context_(NULL), - pixel_buffer_object_(0) { -} - -ScopedPixelBufferObject::~ScopedPixelBufferObject() { - Release(); -} - -bool ScopedPixelBufferObject::Init(CGLContextObj cgl_context, - int size_in_bytes) { - cgl_context_ = cgl_context; - CGLContextObj CGL_MACRO_CONTEXT = cgl_context_; - glGenBuffersARB(1, &pixel_buffer_object_); - if (glGetError() == GL_NO_ERROR) { - glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pixel_buffer_object_); - glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, size_in_bytes, NULL, - GL_STREAM_READ_ARB); - glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0); - if (glGetError() != GL_NO_ERROR) { - Release(); - } - } else { - cgl_context_ = NULL; - pixel_buffer_object_ = 0; - } - return pixel_buffer_object_ != 0; -} - -void ScopedPixelBufferObject::Release() { - if (pixel_buffer_object_) { - CGLContextObj CGL_MACRO_CONTEXT = cgl_context_; - glDeleteBuffersARB(1, &pixel_buffer_object_); - cgl_context_ = NULL; - pixel_buffer_object_ = 0; - } -} - -} // namespace webrtc diff --git a/modules/desktop_capture/mac/scoped_pixel_buffer_object.h b/modules/desktop_capture/mac/scoped_pixel_buffer_object.h deleted file mode 100644 index 1790e873d7..0000000000 --- a/modules/desktop_capture/mac/scoped_pixel_buffer_object.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef MODULES_DESKTOP_CAPTURE_SCOPED_PIXEL_BUFFER_OBJECT_H_ -#define MODULES_DESKTOP_CAPTURE_SCOPED_PIXEL_BUFFER_OBJECT_H_ - -#include -#include - -#include "rtc_base/constructormagic.h" -#include "typedefs.h" // NOLINT(build/include) - -namespace webrtc { - -class ScopedPixelBufferObject { - public: - ScopedPixelBufferObject(); - ~ScopedPixelBufferObject(); - - bool Init(CGLContextObj cgl_context, int size_in_bytes); - void Release(); - - GLuint get() const { return pixel_buffer_object_; } - - private: - CGLContextObj cgl_context_; - GLuint pixel_buffer_object_; - - RTC_DISALLOW_COPY_AND_ASSIGN(ScopedPixelBufferObject); -}; - -} // namespace webrtc - -#endif // MODULES_DESKTOP_CAPTURE_SCOPED_PIXEL_BUFFER_OBJECT_H_ diff --git a/modules/desktop_capture/mac/screen_capturer_mac.h b/modules/desktop_capture/mac/screen_capturer_mac.h index 13eb5ea893..0191317062 100644 --- a/modules/desktop_capture/mac/screen_capturer_mac.h +++ b/modules/desktop_capture/mac/screen_capturer_mac.h @@ -22,7 +22,6 @@ #include "modules/desktop_capture/desktop_region.h" #include "modules/desktop_capture/mac/desktop_configuration.h" #include "modules/desktop_capture/mac/desktop_configuration_monitor.h" -#include "modules/desktop_capture/mac/scoped_pixel_buffer_object.h" #include "modules/desktop_capture/screen_capture_frame_queue.h" #include "modules/desktop_capture/screen_capturer_helper.h" #include "modules/desktop_capture/shared_desktop_frame.h" @@ -70,8 +69,6 @@ class ScreenCapturerMac final : public DesktopCapturer { Callback* callback_ = nullptr; - ScopedPixelBufferObject pixel_buffer_object_; - // Queue of the frames buffers. ScreenCaptureFrameQueue queue_; diff --git a/modules/desktop_capture/mac/screen_capturer_mac.mm b/modules/desktop_capture/mac/screen_capturer_mac.mm index c3080d3f14..f4bbe63716 100644 --- a/modules/desktop_capture/mac/screen_capturer_mac.mm +++ b/modules/desktop_capture/mac/screen_capturer_mac.mm @@ -8,21 +8,13 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include - -#include #include -#include -#include -#include - #include "modules/desktop_capture/mac/screen_capturer_mac.h" #include "rtc_base/checks.h" #include "rtc_base/constructormagic.h" #include "rtc_base/logging.h" -#include "rtc_base/macutils.h" #include "rtc_base/timeutils.h" #include "sdk/objc/Framework/Classes/Common/scoped_cftyperef.h" @@ -217,26 +209,6 @@ CGImageRef CreateExcludedWindowRegionImage(const DesktopRect& pixel_bounds, return CGWindowListCreateImageFromArray(window_bounds, window_list, kCGWindowImageDefault); } -// DesktopFrame wrapper that flips wrapped frame upside down by inverting -// stride. -class InvertedDesktopFrame : public DesktopFrame { - public: - InvertedDesktopFrame(std::unique_ptr frame) - : DesktopFrame(frame->size(), - -frame->stride(), - frame->data() + (frame->size().height() - 1) * frame->stride(), - frame->shared_memory()) { - original_frame_ = std::move(frame); - MoveFrameInfoFrom(original_frame_.get()); - } - ~InvertedDesktopFrame() override {} - - private: - std::unique_ptr original_frame_; - - RTC_DISALLOW_COPY_AND_ASSIGN(InvertedDesktopFrame); -}; - } // namespace ScreenCapturerMac::ScreenCapturerMac( @@ -272,8 +244,8 @@ void ScreenCapturerMac::ReleaseBuffers() { } void ScreenCapturerMac::Start(Callback* callback) { - assert(!callback_); - assert(callback); + RTC_DCHECK(!callback_); + RTC_DCHECK(callback); callback_ = callback; } @@ -343,7 +315,7 @@ void ScreenCapturerMac::SetExcludedWindow(WindowId window) { } bool ScreenCapturerMac::GetSourceList(SourceList* screens) { - assert(screens->size() == 0); + RTC_DCHECK(screens->size() == 0); for (MacDisplayConfigurations::iterator it = desktop_config_.displays.begin(); it != desktop_config_.displays.end(); @@ -452,7 +424,7 @@ bool ScreenCapturerMac::CgBlit(const DesktopFrame& frame, const DesktopRegion& r // Request access to the raw pixel data via the image's DataProvider. CGDataProviderRef provider = CGImageGetDataProvider(image); CFDataRef data = CGDataProviderCopyData(provider); - assert(data); + RTC_DCHECK(data); const uint8_t* display_base_address = CFDataGetBytePtr(data); int src_bytes_per_row = CGImageGetBytesPerRow(image); @@ -478,7 +450,7 @@ bool ScreenCapturerMac::CgBlit(const DesktopFrame& frame, const DesktopRegion& r if (excluded_image) { CGDataProviderRef provider = CGImageGetDataProvider(excluded_image); CFDataRef excluded_image_data = CGDataProviderCopyData(provider); - assert(excluded_image_data); + RTC_DCHECK(excluded_image_data); display_base_address = CFDataGetBytePtr(excluded_image_data); src_bytes_per_row = CGImageGetBytesPerRow(excluded_image);