From 594aefa807e1e73461974ba45234d23cee8cfb9a Mon Sep 17 00:00:00 2001 From: "jiayl@webrtc.org" Date: Thu, 19 Jun 2014 22:04:41 +0000 Subject: [PATCH] Do not call CaptureCursor in ScreenCapturerWinGdi if no MouseShapeObserver. It's wasted work and affects frame rate adaptation in Chrome. BUG= R=sergeyu@chromium.org Review URL: https://webrtc-codereview.appspot.com/19789004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@6499 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../desktop_capture/win/screen_capturer_win_gdi.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/webrtc/modules/desktop_capture/win/screen_capturer_win_gdi.cc b/webrtc/modules/desktop_capture/win/screen_capturer_win_gdi.cc index 9cb3681fd..dc10eceb7 100644 --- a/webrtc/modules/desktop_capture/win/screen_capturer_win_gdi.cc +++ b/webrtc/modules/desktop_capture/win/screen_capturer_win_gdi.cc @@ -133,7 +133,8 @@ void ScreenCapturerWinGdi::Capture(const DesktopRegion& region) { callback_->OnCaptureCompleted(frame); // Check for cursor shape update. - CaptureCursor(); + if (mouse_shape_observer_) + CaptureCursor(); } void ScreenCapturerWinGdi::SetMouseShapeObserver( @@ -279,6 +280,8 @@ bool ScreenCapturerWinGdi::CaptureImage() { } void ScreenCapturerWinGdi::CaptureCursor() { + assert(mouse_shape_observer_); + CURSORINFO cursor_info; cursor_info.cbSize = sizeof(CURSORINFO); if (!GetCursorInfo(&cursor_info)) { @@ -317,8 +320,7 @@ void ScreenCapturerWinGdi::CaptureCursor() { // Record the last cursor image that we sent to the client. last_cursor_ = *cursor; - if (mouse_shape_observer_) - mouse_shape_observer_->OnCursorShapeChanged(cursor.release()); + mouse_shape_observer_->OnCursorShapeChanged(cursor.release()); } } // namespace webrtc