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 <zijiehe@chromium.org> Reviewed-by: Zijie He <zijiehe@chromium.org> Cr-Commit-Position: refs/heads/master@{#22632}
This commit is contained in:
parent
122ba6c050
commit
6d7b8359b3
@ -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",
|
||||
|
||||
@ -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 <stddef.h>
|
||||
|
||||
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
|
||||
@ -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 <OpenGL/CGLMacro.h>
|
||||
#include <OpenGL/OpenGL.h>
|
||||
|
||||
#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_
|
||||
@ -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<SharedDesktopFrame> queue_;
|
||||
|
||||
|
||||
@ -8,21 +8,13 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <set>
|
||||
#include <utility>
|
||||
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
#include <Cocoa/Cocoa.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#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<DesktopFrame> 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<DesktopFrame> 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);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user