Index: ui/compositor/compositor.cc |
diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc |
index 5c8c4b9193102e8bd6e420e0e061982404f491d6..08a5597d5739c98d10dfa8e78abd2c2d3dbaa537 100644 |
--- a/ui/compositor/compositor.cc |
+++ b/ui/compositor/compositor.cc |
@@ -68,6 +68,8 @@ Compositor::Compositor(ui::ContextFactory* context_factory, |
: context_factory_(context_factory), |
root_layer_(NULL), |
widget_(gfx::kNullAcceleratedWidget), |
+ widget_valid_(false), |
+ output_surface_requested_(false), |
surface_id_allocator_(context_factory->CreateSurfaceIdAllocator()), |
task_runner_(task_runner), |
vsync_manager_(new CompositorVSyncManager()), |
@@ -175,6 +177,7 @@ Compositor::Compositor(ui::ContextFactory* context_factory, |
base::TimeTicks::Now() - before_create); |
host_->SetRootLayer(root_web_layer_); |
host_->set_surface_id_namespace(surface_id_allocator_->id_namespace()); |
+ host_->SetLayerTreeHostClientReady(); |
} |
Compositor::~Compositor() { |
@@ -203,6 +206,7 @@ Compositor::~Compositor() { |
void Compositor::SetOutputSurface( |
scoped_ptr<cc::OutputSurface> output_surface) { |
+ output_surface_requested_ = false; |
host_->SetOutputSurface(output_surface.Pass()); |
} |
@@ -296,12 +300,18 @@ void Compositor::SetAuthoritativeVSyncInterval( |
vsync_manager_->SetAuthoritativeVSyncInterval(interval); |
} |
-void Compositor::SetAcceleratedWidgetAndStartCompositor( |
- gfx::AcceleratedWidget widget) { |
+void Compositor::SetAcceleratedWidget(gfx::AcceleratedWidget widget) { |
// This function should only get called once. |
- DCHECK_EQ(gfx::kNullAcceleratedWidget, widget_); |
+ DCHECK(!widget_valid_); |
widget_ = widget; |
- host_->SetLayerTreeHostClientReady(); |
+ widget_valid_ = true; |
+ if (output_surface_requested_) |
+ context_factory_->CreateOutputSurface(weak_ptr_factory_.GetWeakPtr()); |
+} |
+ |
+gfx::AcceleratedWidget Compositor::widget() const { |
+ DCHECK(widget_valid_); |
+ return widget_; |
} |
scoped_refptr<CompositorVSyncManager> Compositor::vsync_manager() const { |
@@ -386,7 +396,10 @@ void Compositor::Layout() { |
} |
void Compositor::RequestNewOutputSurface() { |
- context_factory_->CreateOutputSurface(weak_ptr_factory_.GetWeakPtr()); |
+ DCHECK(!output_surface_requested_); |
+ output_surface_requested_ = true; |
+ if (widget_valid_) |
+ context_factory_->CreateOutputSurface(weak_ptr_factory_.GetWeakPtr()); |
} |
void Compositor::DidInitializeOutputSurface() { |