Update ResolutionChangeDetector to make it match common practices
ResolutionChangeDetector now does not update its internal state. There is no impact because Reset() is always actively called. So this change renames ResolutionChangeDetector to ResolutionTracker, and rename the IsChanged() function into SetResolution(), which returns true if a replacement happened. Internally it always records the latest DesktopSize. Customers of this class can still use SetResolution() function to check whether a DesktopSize change happened. Bug: webrtc:8038 Change-Id: I6d25f3dd2d0567219a82b6688bf3e08560c8b0af Reviewed-on: https://chromium-review.googlesource.com/587405 Reviewed-by: Jamie Walch <jamiewalch@chromium.org> Commit-Queue: Zijie He <zijiehe@chromium.org> Cr-Commit-Position: refs/heads/master@{#19184}
This commit is contained in:
parent
e2173d9f0d
commit
7e1c24cba7
@ -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",
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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_
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -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_) {
|
||||
|
||||
@ -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<SharedDesktopFrame> frame_;
|
||||
Context context_;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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<DesktopFrame> frame_;
|
||||
ResolutionChangeDetector resolution_change_detector_;
|
||||
ResolutionTracker resolution_tracker_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user