diff --git a/webrtc/modules/desktop_capture/BUILD.gn b/webrtc/modules/desktop_capture/BUILD.gn index 59c317942d..b0297e96d6 100644 --- a/webrtc/modules/desktop_capture/BUILD.gn +++ b/webrtc/modules/desktop_capture/BUILD.gn @@ -203,8 +203,8 @@ rtc_static_library("desktop_capture") { "mouse_cursor_monitor.h", "mouse_cursor_monitor_mac.mm", "mouse_cursor_monitor_win.cc", - "resolution_change_detector.cc", - "resolution_change_detector.h", + "resolution_tracker.cc", + "resolution_tracker.h", "rgba_color.cc", "rgba_color.h", "screen_capture_frame_queue.h", diff --git a/webrtc/modules/desktop_capture/resolution_change_detector.cc b/webrtc/modules/desktop_capture/resolution_tracker.cc similarity index 70% rename from webrtc/modules/desktop_capture/resolution_change_detector.cc rename to webrtc/modules/desktop_capture/resolution_tracker.cc index f61a5352fb..326e47460a 100644 --- a/webrtc/modules/desktop_capture/resolution_change_detector.cc +++ b/webrtc/modules/desktop_capture/resolution_tracker.cc @@ -8,21 +8,26 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/modules/desktop_capture/resolution_change_detector.h" +#include "webrtc/modules/desktop_capture/resolution_tracker.h" namespace webrtc { -bool ResolutionChangeDetector::IsChanged(DesktopSize size) { +bool ResolutionTracker::SetResolution(DesktopSize size) { if (!initialized_) { initialized_ = true; last_size_ = size; return false; } - return !last_size_.equals(size); + if (last_size_.equals(size)) { + return false; + } + + last_size_ = size; + return true; } -void ResolutionChangeDetector::Reset() { +void ResolutionTracker::Reset() { initialized_ = false; } diff --git a/webrtc/modules/desktop_capture/resolution_change_detector.h b/webrtc/modules/desktop_capture/resolution_tracker.h similarity index 57% rename from webrtc/modules/desktop_capture/resolution_change_detector.h rename to webrtc/modules/desktop_capture/resolution_tracker.h index f82c3900a1..243333d053 100644 --- a/webrtc/modules/desktop_capture/resolution_change_detector.h +++ b/webrtc/modules/desktop_capture/resolution_tracker.h @@ -8,19 +8,18 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_RESOLUTION_CHANGE_DETECTOR_H_ -#define WEBRTC_MODULES_DESKTOP_CAPTURE_RESOLUTION_CHANGE_DETECTOR_H_ +#ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_RESOLUTION_TRACKER_H_ +#define WEBRTC_MODULES_DESKTOP_CAPTURE_RESOLUTION_TRACKER_H_ #include "webrtc/modules/desktop_capture/desktop_geometry.h" namespace webrtc { -class ResolutionChangeDetector { +class ResolutionTracker final { public: - // Checks whether the |size| has been changed comparing to the |size| passed - // in during last IsChanged() call. This function won't return false for the - // first time after construction or Reset() call. - bool IsChanged(DesktopSize size); + // Sets the resolution to |size|. Returns true if a previous size was recorded + // and differs from |size|. + bool SetResolution(DesktopSize size); // Resets to the initial state. void Reset(); @@ -32,4 +31,4 @@ class ResolutionChangeDetector { } // namespace webrtc -#endif // WEBRTC_MODULES_DESKTOP_CAPTURE_RESOLUTION_CHANGE_DETECTOR_H_ +#endif // WEBRTC_MODULES_DESKTOP_CAPTURE_RESOLUTION_TRACKER_H_ diff --git a/webrtc/modules/desktop_capture/win/display_configuration_monitor.h b/webrtc/modules/desktop_capture/win/display_configuration_monitor.h index d13b45ed35..0937c33815 100644 --- a/webrtc/modules/desktop_capture/win/display_configuration_monitor.h +++ b/webrtc/modules/desktop_capture/win/display_configuration_monitor.h @@ -21,7 +21,7 @@ namespace webrtc { class DisplayConfigurationMonitor { public: // Checks whether the change of display configuration has happened after last - // IsChanged() call. This function won't return false for the first time after + // IsChanged() call. This function won't return true for the first time after // constructor or Reset() call. bool IsChanged(); diff --git a/webrtc/modules/desktop_capture/win/dxgi_frame.cc b/webrtc/modules/desktop_capture/win/dxgi_frame.cc index 5213f9059e..884c63aec8 100644 --- a/webrtc/modules/desktop_capture/win/dxgi_frame.cc +++ b/webrtc/modules/desktop_capture/win/dxgi_frame.cc @@ -33,10 +33,10 @@ bool DxgiFrame::Prepare(DesktopSize size, DesktopCapturer::SourceId source_id) { context_.Reset(); } - if (resolution_change_detector_.IsChanged(size)) { + if (resolution_tracker_.SetResolution(size)) { // Once the output size changed, recreate the SharedDesktopFrame. frame_.reset(); - resolution_change_detector_.Reset(); + resolution_tracker_.Reset(); } if (!frame_) { diff --git a/webrtc/modules/desktop_capture/win/dxgi_frame.h b/webrtc/modules/desktop_capture/win/dxgi_frame.h index e31c5b8b36..236ae48011 100644 --- a/webrtc/modules/desktop_capture/win/dxgi_frame.h +++ b/webrtc/modules/desktop_capture/win/dxgi_frame.h @@ -17,7 +17,7 @@ #include "webrtc/modules/desktop_capture/desktop_capturer.h" #include "webrtc/modules/desktop_capture/desktop_capture_types.h" #include "webrtc/modules/desktop_capture/desktop_geometry.h" -#include "webrtc/modules/desktop_capture/resolution_change_detector.h" +#include "webrtc/modules/desktop_capture/resolution_tracker.h" #include "webrtc/modules/desktop_capture/shared_desktop_frame.h" #include "webrtc/modules/desktop_capture/shared_memory.h" #include "webrtc/modules/desktop_capture/win/dxgi_context.h" @@ -52,7 +52,7 @@ class DxgiFrame final { Context* context(); SharedMemoryFactory* const factory_; - ResolutionChangeDetector resolution_change_detector_; + ResolutionTracker resolution_tracker_; DesktopCapturer::SourceId source_id_ = kFullDesktopScreenId; std::unique_ptr frame_; Context context_; diff --git a/webrtc/modules/desktop_capture/win/dxgi_texture.cc b/webrtc/modules/desktop_capture/win/dxgi_texture.cc index 60f181bc93..6c19ee0932 100644 --- a/webrtc/modules/desktop_capture/win/dxgi_texture.cc +++ b/webrtc/modules/desktop_capture/win/dxgi_texture.cc @@ -57,7 +57,7 @@ bool DxgiTexture::CopyFrom(const DXGI_OUTDUPL_FRAME_INFO& frame_info, D3D11_TEXTURE2D_DESC desc = {0}; texture->GetDesc(&desc); desktop_size_.set(desc.Width, desc.Height); - if (resolution_change_detector_.IsChanged(desktop_size_)) { + if (resolution_tracker_.SetResolution(desktop_size_)) { LOG(LS_ERROR) << "Texture size is not consistent with current DxgiTexture."; return false; } diff --git a/webrtc/modules/desktop_capture/win/dxgi_texture.h b/webrtc/modules/desktop_capture/win/dxgi_texture.h index 6f3e29b07f..c2b0db4c9e 100644 --- a/webrtc/modules/desktop_capture/win/dxgi_texture.h +++ b/webrtc/modules/desktop_capture/win/dxgi_texture.h @@ -18,7 +18,7 @@ #include "webrtc/modules/desktop_capture/desktop_frame.h" #include "webrtc/modules/desktop_capture/desktop_geometry.h" -#include "webrtc/modules/desktop_capture/resolution_change_detector.h" +#include "webrtc/modules/desktop_capture/resolution_tracker.h" namespace webrtc { @@ -67,7 +67,7 @@ class DxgiTexture { DXGI_MAPPED_RECT rect_ = {0}; DesktopSize desktop_size_; std::unique_ptr frame_; - ResolutionChangeDetector resolution_change_detector_; + ResolutionTracker resolution_tracker_; }; } // namespace webrtc