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

Unified Diff: content/browser/compositor/delegated_frame_host.cc

Issue 986823002: De-dupe copy requests for tab capture in DelegatedFrameHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove redundant portion of new test. Created 5 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: content/browser/compositor/delegated_frame_host.cc
diff --git a/content/browser/compositor/delegated_frame_host.cc b/content/browser/compositor/delegated_frame_host.cc
index e6cb16150673df0c4db6cc80b28610e4154792a2..135961f051ad0b315084bc442078d907b1548c3c 100644
--- a/content/browser/compositor/delegated_frame_host.cc
+++ b/content/browser/compositor/delegated_frame_host.cc
@@ -64,6 +64,7 @@ DelegatedFrameHost::DelegatedFrameHost(DelegatedFrameHostClient* client)
skipped_frames_(false),
current_scale_factor_(1.f),
can_lock_compositor_(YES_CAN_LOCK),
+ frame_subscriber_copy_request_pending_(false),
delegated_frame_evictor_(new DelegatedFrameEvictor(this)) {
ImageTransportFactory::GetInstance()->AddObserver(this);
}
@@ -269,6 +270,18 @@ void DelegatedFrameHost::DidReceiveFrameFromRenderer(
RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback callback;
if (frame_subscriber()->ShouldCaptureFrame(damage_rect, present_time,
&frame, &callback)) {
+ if (frame_subscriber_copy_request_pending_) {
+ // A copy request was made for the previous frame from the renderer, but
+ // drawing never started (which executes the request). Therefore, that
+ // request is still alive; and this request should be immediately aborted.
+ // Note that this de-duping check must be done after the call to
+ // ShouldCaptureFrame() above, since the frame subscriber makes decisions
+ // based on the renderer's intentions, and not the performance of the
+ // browser compositor.
+ callback.Run(present_time, false);
+ return;
+ }
+ frame_subscriber_copy_request_pending_ = true;
CopyFromCompositingSurfaceToVideoFrame(
gfx::Rect(current_frame_size_in_dip_),
frame,
@@ -854,6 +867,7 @@ void DelegatedFrameHost::OnCompositingDidCommit(
void DelegatedFrameHost::OnCompositingStarted(
ui::Compositor* compositor, base::TimeTicks start_time) {
last_draw_ended_ = start_time;
+ frame_subscriber_copy_request_pending_ = false;
}
void DelegatedFrameHost::OnCompositingEnded(

Powered by Google App Engine
This is Rietveld 408576698