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

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: address comments on PS#2 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..1a4ed3750c727708fccea44c4753be47e7ecfda1 100644
--- a/media/capture/content/video_capture_oracle.cc
+++ b/media/capture/content/video_capture_oracle.cc
@@ -101,6 +101,7 @@ VideoCaptureOracle::VideoCaptureOracle(
bool enable_auto_throttling)
: auto_throttling_enabled_(enable_auto_throttling),
next_frame_number_(0),
+ source_is_dirty_(true),
last_successfully_delivered_frame_number_(-1),
num_frames_pending_(0),
smoothing_sampler_(min_capture_period),
@@ -138,6 +139,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 +166,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.
@@ -221,6 +230,8 @@ int VideoCaptureOracle::next_frame_number() const {
void VideoCaptureOracle::RecordCapture(double pool_utilization) {
DCHECK(std::isfinite(pool_utilization) && pool_utilization >= 0.0);
+ source_is_dirty_ = false;
+
smoothing_sampler_.RecordSample();
const base::TimeTicks timestamp = GetFrameTimestamp(next_frame_number_);
content_sampler_.RecordSample(timestamp);
@@ -271,6 +282,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;
}
« no previous file with comments | « media/capture/content/video_capture_oracle.h ('k') | media/capture/content/video_capture_oracle_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698