Commit 561d774c authored by Saman Sami's avatar Saman Sami Committed by Commit Bot

viz: Add method to disable auto throttling in FrameSinkVideoCapturer

As long as DevTools eyedropper tool is concerned, a snapshot is useless
if any sort of downscaling has happened on it. Add an option to disable
auto-throttling so that we get the highest resolution possible in any
circumstances. Also added a missing call to SetMinSizeChangePeriod.

Bug: 813929
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel
Change-Id: I9cca167e6f015bd12d8ce64c9ba04d87847f1c44
Reviewed-on: https://chromium-review.googlesource.com/963309
Commit-Queue: Saman Sami <samans@chromium.org>
Reviewed-by: default avatarYuri Wiitala <miu@chromium.org>
Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarAndrey Kosyakov <caseq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543918}
parent 7f91b6db
...@@ -66,6 +66,8 @@ void DevToolsEyeDropper::AttachToHost(content::RenderWidgetHost* host) { ...@@ -66,6 +66,8 @@ void DevToolsEyeDropper::AttachToHost(content::RenderWidgetHost* host) {
gfx::Size(1, 1), gfx::Size(1, 1),
gfx::Size(media::limits::kMaxDimension, media::limits::kMaxDimension), gfx::Size(media::limits::kMaxDimension, media::limits::kMaxDimension),
false); false);
video_capturer_->SetAutoThrottlingEnabled(false);
video_capturer_->SetMinSizeChangePeriod(base::TimeDelta());
video_capturer_->SetMinCapturePeriod(base::TimeDelta::FromSeconds(1) / video_capturer_->SetMinCapturePeriod(base::TimeDelta::FromSeconds(1) /
kMaxFrameRate); kMaxFrameRate);
......
...@@ -215,6 +215,10 @@ void FrameSinkVideoCapturerImpl::SetResolutionConstraints( ...@@ -215,6 +215,10 @@ void FrameSinkVideoCapturerImpl::SetResolutionConstraints(
RefreshEntireSourceSoon(); RefreshEntireSourceSoon();
} }
void FrameSinkVideoCapturerImpl::SetAutoThrottlingEnabled(bool enabled) {
oracle_.SetAutoThrottlingEnabled(enabled);
}
void FrameSinkVideoCapturerImpl::ChangeTarget( void FrameSinkVideoCapturerImpl::ChangeTarget(
const FrameSinkId& frame_sink_id) { const FrameSinkId& frame_sink_id) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
......
...@@ -99,6 +99,7 @@ class VIZ_SERVICE_EXPORT FrameSinkVideoCapturerImpl final ...@@ -99,6 +99,7 @@ class VIZ_SERVICE_EXPORT FrameSinkVideoCapturerImpl final
void SetResolutionConstraints(const gfx::Size& min_size, void SetResolutionConstraints(const gfx::Size& min_size,
const gfx::Size& max_size, const gfx::Size& max_size,
bool use_fixed_aspect_ratio) final; bool use_fixed_aspect_ratio) final;
void SetAutoThrottlingEnabled(bool enabled) final;
void ChangeTarget(const FrameSinkId& frame_sink_id) final; void ChangeTarget(const FrameSinkId& frame_sink_id) final;
void Start(mojom::FrameSinkVideoConsumerPtr consumer) final; void Start(mojom::FrameSinkVideoConsumerPtr consumer) final;
void Stop() final; void Stop() final;
......
...@@ -91,6 +91,7 @@ class MockFrameSinkVideoCapturer : public viz::mojom::FrameSinkVideoCapturer { ...@@ -91,6 +91,7 @@ class MockFrameSinkVideoCapturer : public viz::mojom::FrameSinkVideoCapturer {
void(const gfx::Size& min_size, void(const gfx::Size& min_size,
const gfx::Size& max_size, const gfx::Size& max_size,
bool use_fixed_aspect_ratio)); bool use_fixed_aspect_ratio));
MOCK_METHOD1(SetAutoThrottlingEnabled, void(bool));
MOCK_METHOD1(ChangeTarget, void(const viz::FrameSinkId& frame_sink_id)); MOCK_METHOD1(ChangeTarget, void(const viz::FrameSinkId& frame_sink_id));
void Start(viz::mojom::FrameSinkVideoConsumerPtr consumer) final { void Start(viz::mojom::FrameSinkVideoConsumerPtr consumer) final {
DCHECK_NOT_ON_DEVICE_THREAD(); DCHECK_NOT_ON_DEVICE_THREAD();
......
...@@ -108,6 +108,20 @@ void VideoCaptureOracle::SetCaptureSizeConstraints( ...@@ -108,6 +108,20 @@ void VideoCaptureOracle::SetCaptureSizeConstraints(
use_fixed_aspect_ratio); use_fixed_aspect_ratio);
} }
void VideoCaptureOracle::SetAutoThrottlingEnabled(bool enabled) {
if (auto_throttling_enabled_ == enabled)
return;
auto_throttling_enabled_ = enabled;
// When not auto-throttling, have the CaptureResolutionChooser target the max
// resolution within constraints.
if (!enabled)
resolution_chooser_.SetTargetFrameArea(std::numeric_limits<int>::max());
if (next_frame_number_ > 0)
CommitCaptureSizeAndReset(GetFrameTimestamp(next_frame_number_ - 1));
}
void VideoCaptureOracle::SetSourceSize(const gfx::Size& source_size) { void VideoCaptureOracle::SetSourceSize(const gfx::Size& source_size) {
resolution_chooser_.SetSourceSize(source_size); resolution_chooser_.SetSourceSize(source_size);
// If the |resolution_chooser_| computed a new capture size, that will become // If the |resolution_chooser_| computed a new capture size, that will become
......
...@@ -51,6 +51,10 @@ class CAPTURE_EXPORT VideoCaptureOracle { ...@@ -51,6 +51,10 @@ class CAPTURE_EXPORT VideoCaptureOracle {
const gfx::Size& max_size, const gfx::Size& max_size,
bool use_fixed_aspect_ratio); bool use_fixed_aspect_ratio);
// Specifies whether the oracle should automatically adjust the capture size
// in response to end-to-end utilization.
void SetAutoThrottlingEnabled(bool enabled);
// Get/Update the source content size. Changes may not have an immediate // Get/Update the source content size. Changes may not have an immediate
// effect on the proposed capture size, as the oracle will prevent too- // effect on the proposed capture size, as the oracle will prevent too-
// frequent changes from occurring. // frequent changes from occurring.
...@@ -181,7 +185,7 @@ class CAPTURE_EXPORT VideoCaptureOracle { ...@@ -181,7 +185,7 @@ class CAPTURE_EXPORT VideoCaptureOracle {
// Set to false to prevent the oracle from automatically adjusting the capture // Set to false to prevent the oracle from automatically adjusting the capture
// size in response to end-to-end utilization. // size in response to end-to-end utilization.
const bool auto_throttling_enabled_; bool auto_throttling_enabled_;
// The minimum amount of time that must pass between changes to the capture // The minimum amount of time that must pass between changes to the capture
// size. // size.
......
...@@ -88,7 +88,9 @@ interface FrameSinkVideoCapturer { ...@@ -88,7 +88,9 @@ interface FrameSinkVideoCapturer {
// Specifies the minimum amount of time that must elapse between changing the // Specifies the minimum amount of time that must elapse between changing the
// size of video frames. This can be set to zero to disable resize throttling, // size of video frames. This can be set to zero to disable resize throttling,
// which means each video frame could have a different size. // which means each video frame could have a different size. Note that
// setting this period too low can result in erratic frame sizing behaviour;
// consider disabling auto-throttling in such cases.
// //
// Default, if never called: 3 seconds. // Default, if never called: 3 seconds.
SetMinSizeChangePeriod(mojo.common.mojom.TimeDelta min_period); SetMinSizeChangePeriod(mojo.common.mojom.TimeDelta min_period);
...@@ -107,6 +109,15 @@ interface FrameSinkVideoCapturer { ...@@ -107,6 +109,15 @@ interface FrameSinkVideoCapturer {
SetResolutionConstraints(gfx.mojom.Size min_size, gfx.mojom.Size max_size, SetResolutionConstraints(gfx.mojom.Size min_size, gfx.mojom.Size max_size,
bool use_fixed_aspect_ratio); bool use_fixed_aspect_ratio);
// Specifies whether capture resolution should be automatically adjusted
// within the bounds provided to SetReslutionConstraints in response to
// utilization feedback from the consumer and the buffer pool. When set to
// false, the capturer will always use the highest resolution within
// constraints that doesn't exceed the source size.
//
// Default, if never called: true.
SetAutoThrottlingEnabled(bool enabled);
// Targets a different compositor frame sink. This may be called anytime, // Targets a different compositor frame sink. This may be called anytime,
// before or after Start(). // before or after Start().
ChangeTarget(FrameSinkId frame_sink_id); ChangeTarget(FrameSinkId frame_sink_id);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment