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

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

Issue 578383004: Limit outstanding surface draw swaps to max_frames_pending. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « content/browser/compositor/onscreen_display_client.h ('k') | mojo/services/surfaces/surfaces_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/compositor/onscreen_display_client.cc
diff --git a/content/browser/compositor/onscreen_display_client.cc b/content/browser/compositor/onscreen_display_client.cc
index da60316490f034c0e8f530e1a0b713dcca816173..2ca7a75bd67dd90545beb10b516f122f47b069a6 100644
--- a/content/browser/compositor/onscreen_display_client.cc
+++ b/content/browser/compositor/onscreen_display_client.cc
@@ -21,6 +21,8 @@ OnscreenDisplayClient::OnscreenDisplayClient(
new cc::Display(this, manager, HostSharedBitmapManager::current())),
task_runner_(task_runner),
scheduled_draw_(false),
+ deferred_draw_(false),
+ pending_frames_(0),
weak_ptr_factory_(this) {
}
@@ -33,9 +35,19 @@ scoped_ptr<cc::OutputSurface> OnscreenDisplayClient::CreateOutputSurface() {
}
void OnscreenDisplayClient::DisplayDamaged() {
- if (scheduled_draw_)
+ if (scheduled_draw_ || deferred_draw_)
return;
TRACE_EVENT0("content", "OnscreenDisplayClient::DisplayDamaged");
+ if (pending_frames_ >= display_->GetMaxFramesPending()) {
+ deferred_draw_ = true;
+ } else {
+ ScheduleDraw();
+ }
+}
+
+void OnscreenDisplayClient::ScheduleDraw() {
+ DCHECK(!deferred_draw_);
+ DCHECK(!scheduled_draw_);
scheduled_draw_ = true;
task_runner_->PostTask(
FROM_HERE,
@@ -48,4 +60,16 @@ void OnscreenDisplayClient::Draw() {
display_->Draw();
}
+void OnscreenDisplayClient::DidSwapBuffers() {
+ pending_frames_++;
+}
+
+void OnscreenDisplayClient::DidSwapBuffersComplete() {
+ pending_frames_--;
+ if ((pending_frames_ < display_->GetMaxFramesPending()) && deferred_draw_) {
+ deferred_draw_ = false;
+ ScheduleDraw();
+ }
+}
+
} // namespace content
« no previous file with comments | « content/browser/compositor/onscreen_display_client.h ('k') | mojo/services/surfaces/surfaces_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698