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

Unified Diff: webrtc/modules/desktop_capture/screen_capturer_mac.mm

Issue 1902323002: Modify ScreenCaptureFrameQueue into a template (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix build break in linux Created 4 years, 8 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
Index: webrtc/modules/desktop_capture/screen_capturer_mac.mm
diff --git a/webrtc/modules/desktop_capture/screen_capturer_mac.mm b/webrtc/modules/desktop_capture/screen_capturer_mac.mm
index c41dc4d7a3b4ba59e4ebe6880f1e090dae5386b5..422d514a3aa1db993e77422476cc5814f7e817ba 100644
--- a/webrtc/modules/desktop_capture/screen_capturer_mac.mm
+++ b/webrtc/modules/desktop_capture/screen_capturer_mac.mm
@@ -22,6 +22,7 @@
#include <OpenGL/CGLMacro.h>
#include <OpenGL/OpenGL.h>
+#include "webrtc/base/checks.h"
#include "webrtc/base/macutils.h"
#include "webrtc/modules/desktop_capture/desktop_capture_options.h"
#include "webrtc/modules/desktop_capture/desktop_frame.h"
@@ -30,8 +31,9 @@
#include "webrtc/modules/desktop_capture/mac/desktop_configuration.h"
#include "webrtc/modules/desktop_capture/mac/desktop_configuration_monitor.h"
#include "webrtc/modules/desktop_capture/mac/scoped_pixel_buffer_object.h"
-#include "webrtc/modules/desktop_capture/screen_capture_frame_queue.h"
+#include "webrtc/modules/desktop_capture/screen_capture_queue.h"
#include "webrtc/modules/desktop_capture/screen_capturer_helper.h"
+#include "webrtc/modules/desktop_capture/shared_desktop_frame.h"
#include "webrtc/system_wrappers/include/logging.h"
#include "webrtc/system_wrappers/include/tick_util.h"
@@ -226,7 +228,7 @@ class ScreenCapturerMac : public ScreenCapturer {
void *user_parameter);
void ReleaseBuffers();
- DesktopFrame* CreateFrame();
+ std::unique_ptr<DesktopFrame> CreateFrame();
Callback* callback_;
@@ -234,7 +236,7 @@ class ScreenCapturerMac : public ScreenCapturer {
ScopedPixelBufferObject pixel_buffer_object_;
// Queue of the frames buffers.
- ScreenCaptureFrameQueue queue_;
+ ScreenCaptureQueue<SharedDesktopFrame> queue_;
// Current display configuration.
MacDesktopConfiguration desktop_config_;
@@ -383,7 +385,8 @@ void ScreenCapturerMac::Start(Callback* callback) {
void ScreenCapturerMac::Capture(const DesktopRegion& region_to_capture) {
TickTime capture_start_time = TickTime::Now();
- queue_.MoveToNextFrame();
+ queue_.MoveToNext();
+ RTC_DCHECK(!queue_.current() || !queue_.current()->IsShared());
desktop_config_monitor_->Lock();
MacDesktopConfiguration new_config =
@@ -404,10 +407,10 @@ void ScreenCapturerMac::Capture(const DesktopRegion& region_to_capture) {
// If the current buffer is from an older generation then allocate a new one.
// Note that we can't reallocate other buffers at this point, since the caller
// may still be reading from them.
- if (!queue_.current_frame())
- queue_.ReplaceCurrentFrame(CreateFrame());
+ if (!queue_.current())
+ queue_.ReplaceCurrent(SharedDesktopFrame::Wrap(CreateFrame()));
- DesktopFrame* current_frame = queue_.current_frame();
+ DesktopFrame* current_frame = queue_.current();
bool flip = false; // GL capturers need flipping.
if (rtc::GetOSVersionName() >= rtc::kMacOSLion) {
@@ -431,7 +434,7 @@ void ScreenCapturerMac::Capture(const DesktopRegion& region_to_capture) {
CgBlitPreLion(*current_frame, region);
}
- DesktopFrame* new_frame = queue_.current_frame()->Share();
+ DesktopFrame* new_frame = queue_.current()->Share();
*new_frame->mutable_updated_region() = region;
if (flip)
@@ -497,7 +500,7 @@ void ScreenCapturerMac::GlBlitFast(const DesktopFrame& frame,
const DesktopRegion& region) {
// Clip to the size of our current screen.
DesktopRect clip_rect = DesktopRect::MakeSize(frame.size());
- if (queue_.previous_frame()) {
+ if (queue_.previous()) {
// We are doing double buffer for the capture data so we just need to copy
// the invalid region from the previous capture in the current buffer.
// TODO(hclam): We can reduce the amount of copying here by subtracting
@@ -512,7 +515,7 @@ void ScreenCapturerMac::GlBlitFast(const DesktopFrame& frame,
DesktopRect copy_rect = i.rect();
copy_rect.IntersectWith(clip_rect);
if (!copy_rect.is_empty()) {
- CopyRect(queue_.previous_frame()->data() + y_offset,
+ CopyRect(queue_.previous()->data() + y_offset,
-frame.stride(),
frame.data() + y_offset,
-frame.stride(),
@@ -581,9 +584,9 @@ void ScreenCapturerMac::CgBlitPreLion(const DesktopFrame& frame,
// Copy the entire contents of the previous capture buffer, to capture over.
// TODO(wez): Get rid of this as per crbug.com/145064, or implement
// crbug.com/92354.
- if (queue_.previous_frame()) {
+ if (queue_.previous()) {
memcpy(frame.data(),
- queue_.previous_frame()->data(),
+ queue_.previous()->data(),
frame.stride() * frame.size().height());
}
@@ -636,9 +639,9 @@ bool ScreenCapturerMac::CgBlitPostLion(const DesktopFrame& frame,
// Copy the entire contents of the previous capture buffer, to capture over.
// TODO(wez): Get rid of this as per crbug.com/145064, or implement
// crbug.com/92354.
- if (queue_.previous_frame()) {
+ if (queue_.previous()) {
memcpy(frame.data(),
- queue_.previous_frame()->data(),
+ queue_.previous()->data(),
frame.stride() * frame.size().height());
}
@@ -964,13 +967,13 @@ void ScreenCapturerMac::ScreenUpdateMoveCallback(
capturer->ScreenUpdateMove(delta, count, rect_array);
}
-DesktopFrame* ScreenCapturerMac::CreateFrame() {
+std::unique_ptr<DesktopFrame> ScreenCapturerMac::CreateFrame() {
std::unique_ptr<DesktopFrame> frame(
new BasicDesktopFrame(screen_pixel_bounds_.size()));
frame->set_dpi(DesktopVector(kStandardDPI * dip_to_pixel_scale_,
kStandardDPI * dip_to_pixel_scale_));
- return frame.release();
+ return frame;
}
} // namespace

Powered by Google App Engine
This is Rietveld 408576698