From 0544b7fab8cd96a0b2d66bbf7f5375aaebe31289 Mon Sep 17 00:00:00 2001 From: "hclam@chromium.org" Date: Wed, 9 Feb 2011 23:07:15 +0000 Subject: Invalidate fullscreen when a new client connects to chromoting host BUG=72252 TEST=Reconnect and screen looks right Review URL: http://codereview.chromium.org/6469004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74365 0039d316-1c4b-4281-b951-d872f2087c98 --- remoting/host/capturer.cc | 8 ++++++++ remoting/host/capturer.h | 4 ++++ remoting/host/capturer_gdi.cc | 4 +++- remoting/host/capturer_linux.cc | 3 +++ remoting/host/screen_recorder.cc | 13 ++++++++++--- remoting/host/screen_recorder.h | 1 + remoting/host/screen_recorder_unittest.cc | 2 ++ 7 files changed, 31 insertions(+), 4 deletions(-) (limited to 'remoting/host') diff --git a/remoting/host/capturer.cc b/remoting/host/capturer.cc index cf1bac7..59854f1 100644 --- a/remoting/host/capturer.cc +++ b/remoting/host/capturer.cc @@ -85,4 +85,12 @@ void Capturer::FinishCapture(scoped_refptr data, delete callback; } +bool Capturer::IsCaptureFullScreen() { + base::AutoLock auto_inval_rects_lock(inval_rects_lock_); + return inval_rects_.size() == 1u && + inval_rects_.begin()->x() == 0 && inval_rects_.begin()->y() == 0 && + inval_rects_.begin()->width() == width_ && + inval_rects_.begin()->height() == height_; +} + } // namespace remoting diff --git a/remoting/host/capturer.h b/remoting/host/capturer.h index 1282ebe..a769abc 100644 --- a/remoting/host/capturer.h +++ b/remoting/host/capturer.h @@ -114,6 +114,10 @@ class Capturer { void FinishCapture(scoped_refptr data, CaptureCompletedCallback* callback); + // Called by subclasses' CalculateInvalidRects() method to check if + // InvalidateFullScreen() was called by user. + bool IsCaptureFullScreen(); + // Number of screen buffers. static const int kNumBuffers = 2; diff --git a/remoting/host/capturer_gdi.cc b/remoting/host/capturer_gdi.cc index c405f3f..ab325321 100644 --- a/remoting/host/capturer_gdi.cc +++ b/remoting/host/capturer_gdi.cc @@ -88,9 +88,11 @@ void CapturerGdi::ScreenConfigurationChanged() { } void CapturerGdi::CalculateInvalidRects() { - ClearInvalidRects(); CaptureImage(); + if (IsCaptureFullScreen()) + capture_fullscreen_ = true; + if (capture_fullscreen_) { InvalidateFullScreen(); } else { diff --git a/remoting/host/capturer_linux.cc b/remoting/host/capturer_linux.cc index 8c1e74c..b43158a 100644 --- a/remoting/host/capturer_linux.cc +++ b/remoting/host/capturer_linux.cc @@ -202,6 +202,9 @@ bool CapturerLinuxPimpl::Init() { } void CapturerLinuxPimpl::CalculateInvalidRects() { + if (capturer_->IsCaptureFullScreen()) + capture_fullscreen_ = true; + // TODO(ajwong): The capture_fullscreen_ logic here is very ugly. Refactor. // Find the number of events that are outstanding "now." We don't just loop diff --git a/remoting/host/screen_recorder.cc b/remoting/host/screen_recorder.cc index d4ba2cf..b7d4d8f 100644 --- a/remoting/host/screen_recorder.cc +++ b/remoting/host/screen_recorder.cc @@ -79,6 +79,10 @@ void ScreenRecorder::AddConnection( scoped_refptr connection) { ScopedTracer tracer("AddConnection"); + capture_loop_->PostTask( + FROM_HERE, + NewRunnableMethod(this, &ScreenRecorder::DoInvalidateFullScreen)); + // Add the client to the list so it can receive update stream. network_loop_->PostTask( FROM_HERE, @@ -242,6 +246,12 @@ void ScreenRecorder::DoFinishOneRecording() { DoCapture(); } +void ScreenRecorder::DoInvalidateFullScreen() { + DCHECK_EQ(capture_loop_, MessageLoop::current()); + + capturer_->InvalidateFullScreen(); +} + // Network thread -------------------------------------------------------------- void ScreenRecorder::DoSendVideoPacket(VideoPacket* packet) { @@ -291,7 +301,6 @@ void ScreenRecorder::DoAddConnection( scoped_refptr connection) { DCHECK_EQ(network_loop_, MessageLoop::current()); - // TODO(hclam): Force a full frame for next encode. connections_.push_back(connection); } @@ -299,7 +308,6 @@ void ScreenRecorder::DoRemoveClient( scoped_refptr connection) { DCHECK_EQ(network_loop_, MessageLoop::current()); - // TODO(hclam): Is it correct to do to a scoped_refptr? ConnectionToClientList::iterator it = std::find(connections_.begin(), connections_.end(), connection); if (it != connections_.end()) { @@ -345,7 +353,6 @@ void ScreenRecorder::DoEncode( return; } - // TODO(hclam): Invalidate the full screen if there is a new connection added. TraceContext::tracer()->PrintString("Encode start"); encoder()->Encode( capture_data, false, diff --git a/remoting/host/screen_recorder.h b/remoting/host/screen_recorder.h index cddeb56..2fa0fdc 100644 --- a/remoting/host/screen_recorder.h +++ b/remoting/host/screen_recorder.h @@ -121,6 +121,7 @@ class ScreenRecorder : public base::RefCountedThreadSafe { void DoCapture(); void CaptureDoneCallback(scoped_refptr capture_data); void DoFinishOneRecording(); + void DoInvalidateFullScreen(); // Network thread ----------------------------------------------------------- diff --git a/remoting/host/screen_recorder_unittest.cc b/remoting/host/screen_recorder_unittest.cc index cbe3d87..412ce6d 100644 --- a/remoting/host/screen_recorder_unittest.cc +++ b/remoting/host/screen_recorder_unittest.cc @@ -109,6 +109,7 @@ TEST_F(ScreenRecorderTest, OneRecordCycle) { kHeight, kFormat)); EXPECT_CALL(capturer_, width()).WillRepeatedly(Return(kWidth)); EXPECT_CALL(capturer_, height()).WillRepeatedly(Return(kHeight)); + EXPECT_CALL(capturer_, InvalidateFullScreen()); // First the capturer is called. EXPECT_CALL(capturer_, CaptureInvalidRects(NotNull())) @@ -159,6 +160,7 @@ TEST_F(ScreenRecorderTest, StartAndStop) { kHeight, kFormat)); EXPECT_CALL(capturer_, width()).WillRepeatedly(Return(kWidth)); EXPECT_CALL(capturer_, height()).WillRepeatedly(Return(kHeight)); + EXPECT_CALL(capturer_, InvalidateFullScreen()); // First the capturer is called. EXPECT_CALL(capturer_, CaptureInvalidRects(NotNull())) -- cgit v1.1