| Index: media/remoting/remoting_renderer_controller.cc
|
| diff --git a/media/remoting/remoting_renderer_controller.cc b/media/remoting/remoting_renderer_controller.cc
|
| index c9cb743cc1e27004115b9bddcdbd55fee64f70e7..7e470886b0377c4ddb94363c45d6c82eb44e27be 100644
|
| --- a/media/remoting/remoting_renderer_controller.cc
|
| +++ b/media/remoting/remoting_renderer_controller.cc
|
| @@ -9,6 +9,16 @@
|
| #include "base/threading/thread_checker.h"
|
| #include "media/remoting/remoting_cdm_context.h"
|
|
|
| +namespace {
|
| +
|
| +constexpr int64_t kOneHundredPercent = 100;
|
| +
|
| +// The threshold of the percentage of the viewport filled by the media to
|
| +// start remoting.
|
| +constexpr int64_t kFillActivationThresholdPercent = 85;
|
| +
|
| +} // namespace
|
| +
|
| namespace media {
|
|
|
| RemotingRendererController::RemotingRendererController(
|
| @@ -60,6 +70,39 @@ void RemotingRendererController::OnExitedFullscreen() {
|
| UpdateAndMaybeSwitch();
|
| }
|
|
|
| +void RemotingRendererController::OnViewportIntersectionChanged(
|
| + const ViewportIntersectionInfo& info) {
|
| + DCHECK(thread_checker_.CalledOnValidThread());
|
| +
|
| + // Reset on any notification, since this indicates the user is scrolling
|
| + // around in the document, the document is changing layout, etc.
|
| + viewport_fill_debouncer_timer_.Stop();
|
| +
|
| + if (kOneHundredPercent * info.intersect_rect.size().GetArea() <=
|
| + kFillActivationThresholdPercent * info.root_rect.size().GetArea()) {
|
| + if (is_mostly_filling_viewport_) {
|
| + is_mostly_filling_viewport_ = false;
|
| + UpdateAndMaybeSwitch();
|
| + }
|
| + return;
|
| + }
|
| +
|
| + // Meeting/Exceeding the threshold should hold steady for 5 seconds before
|
| + // starting remote rendering.
|
| + if (!is_mostly_filling_viewport_) {
|
| + viewport_fill_debouncer_timer_.Start(
|
| + FROM_HERE, base::TimeDelta::FromSeconds(5),
|
| + base::Bind(
|
| + &RemotingRendererController::OnViewportMostlyFilledAndUnchanging,
|
| + weak_factory_.GetWeakPtr()));
|
| + }
|
| +}
|
| +
|
| +void RemotingRendererController::OnViewportMostlyFilledAndUnchanging() {
|
| + is_mostly_filling_viewport_ = true;
|
| + UpdateAndMaybeSwitch();
|
| +}
|
| +
|
| void RemotingRendererController::OnSetCdm(CdmContext* cdm_context) {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
|
|
| @@ -195,10 +238,10 @@ bool RemotingRendererController::ShouldBeRemoting() {
|
| (has_audio() && !IsAudioCodecSupported()))
|
| return false;
|
|
|
| - // Normally, entering fullscreen is the signal that starts remote rendering.
|
| - // However, current technical limitations require encrypted content be remoted
|
| - // without waiting for a user signal.
|
| - return is_fullscreen_;
|
| + // Normally, entering fullscreen or filling most of the viewport is the signal
|
| + // that starts remote rendering. However, current technical limitations
|
| + // require encrypted content be remoted without waiting for a user signal.
|
| + return is_fullscreen_ || is_mostly_filling_viewport_;
|
| }
|
|
|
| void RemotingRendererController::UpdateAndMaybeSwitch() {
|
|
|