Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(311)

Unified Diff: media/capture/content/video_capture_oracle.cc

Issue 2770923003: TabCapture: enforce active refresh if there is un-sampled compositor update (Closed)
Patch Set: Apply suggested patch Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/capture/content/video_capture_oracle.cc
diff --git a/media/capture/content/video_capture_oracle.cc b/media/capture/content/video_capture_oracle.cc
index b1dcb80adeef3bd307a352afd04843d9f80b5ac5..ada05ff558ca01fff63da9c6e5947c18237ee3b3 100644
--- a/media/capture/content/video_capture_oracle.cc
+++ b/media/capture/content/video_capture_oracle.cc
@@ -101,6 +101,8 @@ VideoCaptureOracle::VideoCaptureOracle(
bool enable_auto_throttling)
: auto_throttling_enabled_(enable_auto_throttling),
next_frame_number_(0),
+ source_is_dirty_(true),
+ last_event_causing_capture_(kPassiveRefreshRequest),
last_successfully_delivered_frame_number_(-1),
num_frames_pending_(0),
smoothing_sampler_(min_capture_period),
@@ -138,6 +140,11 @@ bool VideoCaptureOracle::ObserveEventAndDecideCapture(
}
last_event_time_[event] = event_time;
+ // If the event indicates a change to the source content, set a flag that will
+ // prevent passive refresh requests until a capture is made.
+ if (event != kActiveRefreshRequest && event != kPassiveRefreshRequest)
+ source_is_dirty_ = true;
+
bool should_sample = false;
duration_of_next_frame_ = base::TimeDelta();
switch (event) {
@@ -160,8 +167,11 @@ bool VideoCaptureOracle::ObserveEventAndDecideCapture(
break;
}
- case kActiveRefreshRequest:
case kPassiveRefreshRequest:
+ if (source_is_dirty_)
+ break;
+ // Intentional flow-through to next case here!
+ case kActiveRefreshRequest:
case kMouseCursorUpdate:
// Only allow non-compositor samplings when content has not recently been
// animating, and only if there are no samplings currently in progress.
@@ -182,6 +192,7 @@ bool VideoCaptureOracle::ObserveEventAndDecideCapture(
if (!should_sample)
return false;
+ last_event_causing_capture_ = event;
// If the exact duration of the next frame has not been determined, estimate
// it using the difference between the current and last frame.
@@ -221,6 +232,9 @@ int VideoCaptureOracle::next_frame_number() const {
void VideoCaptureOracle::RecordCapture(double pool_utilization) {
DCHECK(std::isfinite(pool_utilization) && pool_utilization >= 0.0);
+ if (last_event_causing_capture_ != kPassiveRefreshRequest)
miu 2017/03/24 21:17:28 Per discussion, this shouldn't be necessary. So, j
braveyao 2017/03/24 23:12:27 Done.
+ source_is_dirty_ = false;
+
smoothing_sampler_.RecordSample();
const base::TimeTicks timestamp = GetFrameTimestamp(next_frame_number_);
content_sampler_.RecordSample(timestamp);
@@ -271,6 +285,9 @@ bool VideoCaptureOracle::CompleteCapture(int frame_number,
if (!capture_was_successful) {
VLOG(2) << "Capture of frame #" << frame_number << " was not successful.";
+ // Since capture of this frame might have been required for capturing an
+ // update to the source content, set the dirty flag.
+ source_is_dirty_ = true;
return false;
}

Powered by Google App Engine
This is Rietveld 408576698