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

Unified Diff: webrtc/modules/desktop_capture/desktop_and_cursor_composer.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
Index: webrtc/modules/desktop_capture/desktop_and_cursor_composer.cc
diff --git a/webrtc/modules/desktop_capture/desktop_and_cursor_composer.cc b/webrtc/modules/desktop_capture/desktop_and_cursor_composer.cc
index 4c6e27e561eaa19794df980f63bf9028924b697f..a4deda6ae95b915039735fafa7dfe1d454ab3923 100644
--- a/webrtc/modules/desktop_capture/desktop_and_cursor_composer.cc
+++ b/webrtc/modules/desktop_capture/desktop_and_cursor_composer.cc
@@ -57,7 +57,7 @@ void AlphaBlend(uint8_t* dest, int dest_stride,
class DesktopFrameWithCursor : public DesktopFrame {
public:
// Takes ownership of |frame|.
- DesktopFrameWithCursor(DesktopFrame* frame,
+ DesktopFrameWithCursor(std::unique_ptr<DesktopFrame> frame,
const MouseCursor& cursor,
const DesktopVector& position);
virtual ~DesktopFrameWithCursor();
@@ -71,15 +71,18 @@ class DesktopFrameWithCursor : public DesktopFrame {
RTC_DISALLOW_COPY_AND_ASSIGN(DesktopFrameWithCursor);
};
-DesktopFrameWithCursor::DesktopFrameWithCursor(DesktopFrame* frame,
- const MouseCursor& cursor,
- const DesktopVector& position)
- : DesktopFrame(frame->size(), frame->stride(),
- frame->data(), frame->shared_memory()),
- original_frame_(frame) {
+DesktopFrameWithCursor::DesktopFrameWithCursor(
+ std::unique_ptr<DesktopFrame> frame,
+ const MouseCursor& cursor,
+ const DesktopVector& position)
+ : DesktopFrame(frame->size(),
+ frame->stride(),
+ frame->data(),
+ frame->shared_memory()) {
set_dpi(frame->dpi());
set_capture_time_ms(frame->capture_time_ms());
mutable_updated_region()->Swap(frame->mutable_updated_region());
+ original_frame_ = std::move(frame);
DesktopVector image_pos = position.subtract(cursor.hotspot());
DesktopRect target_rect = DesktopRect::MakeSize(cursor.image()->size());
@@ -152,14 +155,15 @@ void DesktopAndCursorComposer::SetExcludedWindow(WindowId window) {
desktop_capturer_->SetExcludedWindow(window);
}
-void DesktopAndCursorComposer::OnCaptureCompleted(DesktopFrame* frame) {
- if (frame && cursor_.get() && cursor_state_ == MouseCursorMonitor::INSIDE) {
- DesktopFrameWithCursor* frame_with_cursor =
- new DesktopFrameWithCursor(frame, *cursor_, cursor_position_);
- frame = frame_with_cursor;
+void DesktopAndCursorComposer::OnCaptureResult(
+ DesktopCapturer::Result result,
+ std::unique_ptr<DesktopFrame> frame) {
+ if (frame && cursor_ && cursor_state_ == MouseCursorMonitor::INSIDE) {
+ frame = std::unique_ptr<DesktopFrameWithCursor>(new DesktopFrameWithCursor(
+ std::move(frame), *cursor_, cursor_position_));
}
- callback_->OnCaptureCompleted(frame);
+ callback_->OnCaptureResult(result, std::move(frame));
}
void DesktopAndCursorComposer::OnMouseCursor(MouseCursor* cursor) {

Powered by Google App Engine
This is Rietveld 408576698