Chromium Code Reviews| Index: content/renderer/gpu/render_widget_compositor.cc |
| diff --git a/content/renderer/gpu/render_widget_compositor.cc b/content/renderer/gpu/render_widget_compositor.cc |
| index 5aab6d1c7a6408137b738aafd65f8938ab8015a7..df3263490014e5081ca56cf4e9c09825c5024aab 100644 |
| --- a/content/renderer/gpu/render_widget_compositor.cc |
| +++ b/content/renderer/gpu/render_widget_compositor.cc |
| @@ -422,9 +422,11 @@ scoped_ptr<RenderWidgetCompositor> RenderWidgetCompositor::Create( |
| RenderWidgetCompositor::RenderWidgetCompositor(RenderWidget* widget, |
| bool threaded) |
| - : threaded_(threaded), |
| + : num_failed_recreate_attempts_(0), |
| + threaded_(threaded), |
| widget_(widget), |
| - send_v8_idle_notification_after_commit_(true) { |
| + send_v8_idle_notification_after_commit_(true), |
| + weak_factory_(this) { |
| CommandLine* cmd = CommandLine::ForCurrentProcess(); |
| if (cmd->HasSwitch(switches::kEnableV8IdleNotificationAfterCommit)) |
| @@ -522,7 +524,7 @@ bool RenderWidgetCompositor::SendMessageToMicroBenchmark( |
| return layer_tree_host_->SendMessageToMicroBenchmark(id, value.Pass()); |
| } |
| -void RenderWidgetCompositor::Initialize(cc::LayerTreeSettings settings) { |
| +void RenderWidgetCompositor::Initialize(const cc::LayerTreeSettings& settings) { |
| scoped_refptr<base::MessageLoopProxy> compositor_message_loop_proxy; |
| scoped_refptr<base::SingleThreadTaskRunner> |
| main_thread_compositor_task_runner(base::MessageLoopProxy::current()); |
| @@ -850,11 +852,33 @@ void RenderWidgetCompositor::ApplyViewportDeltas( |
| top_controls_delta); |
| } |
| -void RenderWidgetCompositor::RequestNewOutputSurface(bool fallback) { |
| - layer_tree_host_->SetOutputSurface(widget_->CreateOutputSurface(fallback)); |
| +void RenderWidgetCompositor::RequestNewOutputSurface() { |
| + bool fallback = |
| + num_failed_recreate_attempts_ >= OUTPUT_SURFACE_RETRIES_BEFORE_FALLBACK; |
| + scoped_ptr<cc::OutputSurface> surface(widget_->CreateOutputSurface(fallback)); |
| + |
| + if (!surface) { |
| + DidFailToInitializeOutputSurface(); |
| + return; |
| + } |
| + |
| + layer_tree_host_->SetOutputSurface(surface.Pass()); |
| } |
| void RenderWidgetCompositor::DidInitializeOutputSurface() { |
| + num_failed_recreate_attempts_ = 0; |
| +} |
| + |
| +void RenderWidgetCompositor::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."; |
|
no sievers
2014/12/02 20:38:07
nit: LOG_IF(FATAL, condition)
enne (OOO)
2014/12/02 21:09:33
Done.
|
| + |
| + base::MessageLoop::current()->PostTask( |
| + FROM_HERE, base::Bind(&RenderWidgetCompositor::RequestNewOutputSurface, |
| + weak_factory_.GetWeakPtr())); |
| } |
| void RenderWidgetCompositor::WillCommit() { |