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

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

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_x11.cc
diff --git a/webrtc/modules/desktop_capture/screen_capturer_x11.cc b/webrtc/modules/desktop_capture/screen_capturer_x11.cc
index 65e682b6f8bdc1bd28ba99d515077122fc105adb..849d1a3802401961b85b7c3a171f677507e7cfae 100644
--- a/webrtc/modules/desktop_capture/screen_capturer_x11.cc
+++ b/webrtc/modules/desktop_capture/screen_capturer_x11.cc
@@ -24,8 +24,9 @@
#include "webrtc/modules/desktop_capture/desktop_capture_options.h"
#include "webrtc/modules/desktop_capture/desktop_frame.h"
#include "webrtc/modules/desktop_capture/differ.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/modules/desktop_capture/x11/x_server_pixel_buffer.h"
#include "webrtc/system_wrappers/include/logging.h"
#include "webrtc/system_wrappers/include/tick_util.h"
@@ -106,7 +107,7 @@ class ScreenCapturerLinux : public ScreenCapturer,
ScreenCapturerHelper helper_;
// Queue of the frames buffers.
- ScreenCaptureFrameQueue queue_;
+ ScreenCaptureQueue<SharedDesktopFrame> queue_;
// Invalid region from the previous capture. This is used to synchronize the
// current with the last buffer used.
@@ -236,7 +237,8 @@ void ScreenCapturerLinux::Start(Callback* callback) {
void ScreenCapturerLinux::Capture(const DesktopRegion& region) {
TickTime capture_start_time = TickTime::Now();
- queue_.MoveToNextFrame();
+ queue_.MoveToNext();
+ RTC_DCHECK(!queue_.current() || !queue_.current()->IsShared());
// Process XEvents for XDamage and cursor shape tracking.
options_.x_display()->ProcessPendingXEvents();
@@ -253,14 +255,14 @@ void ScreenCapturerLinux::Capture(const DesktopRegion& region) {
// If the current frame 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()) {
+ if (!queue_.current()) {
std::unique_ptr<DesktopFrame> frame(
new BasicDesktopFrame(x_server_pixel_buffer_.window_size()));
- queue_.ReplaceCurrentFrame(frame.release());
+ queue_.ReplaceCurrent(SharedDesktopFrame::Wrap(std::move(frame)));
}
// Refresh the Differ helper used by CaptureFrame(), if needed.
- DesktopFrame* frame = queue_.current_frame();
+ DesktopFrame* frame = queue_.current();
if (!use_damage_ && (
!differ_.get() ||
(differ_->width() != frame->size().width()) ||
@@ -308,7 +310,7 @@ bool ScreenCapturerLinux::HandleXEvent(const XEvent& event) {
}
DesktopFrame* ScreenCapturerLinux::CaptureScreen() {
- DesktopFrame* frame = queue_.current_frame()->Share();
+ DesktopFrame* frame = queue_.current()->Share();
assert(x_server_pixel_buffer_.window_size().equals(frame->size()));
// Pass the screen size to the helper, so it can clip the invalid region if it
@@ -319,13 +321,13 @@ DesktopFrame* ScreenCapturerLinux::CaptureScreen() {
// if any. If there isn't a previous frame, that means a screen-resolution
// change occurred, and |invalid_rects| will be updated to include the whole
// screen.
- if (use_damage_ && queue_.previous_frame())
+ if (use_damage_ && queue_.previous())
SynchronizeFrame();
DesktopRegion* updated_region = frame->mutable_updated_region();
x_server_pixel_buffer_.Synchronize();
- if (use_damage_ && queue_.previous_frame()) {
+ if (use_damage_ && queue_.previous()) {
// Atomically fetch and clear the damage region.
XDamageSubtract(display(), damage_handle_, None, damage_region_);
int rects_num = 0;
@@ -358,12 +360,12 @@ DesktopFrame* ScreenCapturerLinux::CaptureScreen() {
DesktopRect screen_rect = DesktopRect::MakeSize(frame->size());
x_server_pixel_buffer_.CaptureRect(screen_rect, frame);
- if (queue_.previous_frame()) {
+ if (queue_.previous()) {
// Full-screen polling, so calculate the invalid rects here, based on the
// changed pixels between current and previous buffers.
RTC_DCHECK(differ_.get() != NULL);
- RTC_DCHECK(queue_.previous_frame()->data());
- differ_->CalcDirtyRegion(queue_.previous_frame()->data(),
+ RTC_DCHECK(queue_.previous()->data());
+ differ_->CalcDirtyRegion(queue_.previous()->data(),
frame->data(), updated_region);
} else {
// No previous buffer, so always invalidate the whole screen, whether
@@ -397,10 +399,10 @@ void ScreenCapturerLinux::SynchronizeFrame() {
// TODO(hclam): We can reduce the amount of copying here by subtracting
// |capturer_helper_|s region from |last_invalid_region_|.
// http://crbug.com/92354
- RTC_DCHECK(queue_.previous_frame());
+ RTC_DCHECK(queue_.previous());
- DesktopFrame* current = queue_.current_frame();
- DesktopFrame* last = queue_.previous_frame();
+ DesktopFrame* current = queue_.current();
+ DesktopFrame* last = queue_.previous();
RTC_DCHECK(current != last);
for (DesktopRegion::Iterator it(last_invalid_region_);
!it.IsAtEnd(); it.Advance()) {

Powered by Google App Engine
This is Rietveld 408576698