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

Unified Diff: ui/compositor/compositor.cc

Issue 812543002: Update from https://crrev.com/308331 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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 | « ui/compositor/compositor.h ('k') | ui/gl/gl_context.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/compositor/compositor.cc
diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc
index 58297e6848f0737683557eb52aa7f41c4b3627de..7fd7fe90317dc3f9783d0313c676f8ba41d4d550 100644
--- a/ui/compositor/compositor.cc
+++ b/ui/compositor/compositor.cc
@@ -108,7 +108,7 @@ Compositor::Compositor(gfx::AcceleratedWidget widget,
draw_on_compositing_end_(false),
swap_state_(SWAP_NONE),
layer_animator_collection_(this),
- schedule_draw_factory_(this) {
+ weak_ptr_factory_(this) {
root_web_layer_ = cc::Layer::Create();
CommandLine* command_line = CommandLine::ForCurrentProcess();
@@ -210,10 +210,27 @@ void Compositor::ScheduleDraw() {
defer_draw_scheduling_ = true;
task_runner_->PostTask(
FROM_HERE,
- base::Bind(&Compositor::Draw, schedule_draw_factory_.GetWeakPtr()));
+ base::Bind(&Compositor::Draw, weak_ptr_factory_.GetWeakPtr()));
}
}
+void Compositor::DidInitializeOutputSurface() {
+ num_failed_recreate_attempts_ = 0;
+}
+
+void Compositor::DidFailToInitializeOutputSurface() {
+ num_failed_recreate_attempts_++;
+
+ // Tolerate a certain number of recreation failures to work around races
+ // in the output-surface-lost machinery.
+ if (num_failed_recreate_attempts_ >= MAX_OUTPUT_SURFACE_RETRIES)
+ LOG(FATAL) << "Failed to create a fallback OutputSurface.";
+
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE, base::Bind(&Compositor::RequestNewOutputSurface,
+ weak_ptr_factory_.GetWeakPtr()));
+}
+
void Compositor::SetRootLayer(Layer* root_layer) {
if (root_layer_ == root_layer)
return;
@@ -367,9 +384,11 @@ void Compositor::Layout() {
disable_schedule_composite_ = false;
}
-void Compositor::RequestNewOutputSurface(bool fallback) {
- host_->SetOutputSurface(
- context_factory_->CreateOutputSurface(this, fallback));
+void Compositor::RequestNewOutputSurface() {
+ bool fallback =
+ num_failed_recreate_attempts_ >= OUTPUT_SURFACE_RETRIES_BEFORE_FALLBACK;
+ context_factory_->CreateOutputSurface(weak_ptr_factory_.GetWeakPtr().get(),
+ fallback);
}
void Compositor::DidCommit() {
« no previous file with comments | « ui/compositor/compositor.h ('k') | ui/gl/gl_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698