Chromium Code Reviews| Index: sky/compositor/layer_host.cc |
| diff --git a/sky/compositor/layer_host.cc b/sky/compositor/layer_host.cc |
| index a1991770c3b4a827fc12f5835b09c1ecaf06d38c..ad2ed69a68ad966b8d8273699ea1925b59cbfd07 100644 |
| --- a/sky/compositor/layer_host.cc |
| +++ b/sky/compositor/layer_host.cc |
| @@ -15,6 +15,7 @@ namespace sky { |
| LayerHost::LayerHost(LayerHostClient* client) |
| : client_(client), |
| + state_(kIdle), |
| surface_holder_(this, client->GetShell()), |
| gl_context_(mojo::GLContext::Create(client->GetShell())), |
| ganesh_context_(gl_context_), |
| @@ -29,6 +30,7 @@ LayerHost::~LayerHost() { |
| void LayerHost::SetNeedsAnimate() { |
| scheduler_.SetNeedsFrame(); |
| + state_ = kWaitingForBeginFrame; |
| } |
| void LayerHost::SetRootLayer(scoped_refptr<Layer> layer) { |
| @@ -39,6 +41,9 @@ void LayerHost::SetRootLayer(scoped_refptr<Layer> layer) { |
| void LayerHost::OnSurfaceIdAvailable(mojo::SurfaceIdPtr surface_id) { |
| client_->OnSurfaceIdAvailable(surface_id.Pass()); |
| + |
| + if (state_ == kWaitingForSurfaceToUploadFrame) |
| + Upload(root_layer_.get()); |
| } |
| void LayerHost::ReturnResources( |
| @@ -48,6 +53,8 @@ void LayerHost::ReturnResources( |
| void LayerHost::BeginFrame(base::TimeTicks frame_time, |
| base::TimeTicks deadline) { |
| + DCHECK_EQ(state_, kWaitingForBeginFrame); |
| + state_ = kProducingFrame; |
| client_->BeginFrame(frame_time); |
| { |
| @@ -57,9 +64,18 @@ void LayerHost::BeginFrame(base::TimeTicks frame_time, |
| } |
| Upload(root_layer_.get()); |
| + |
| + if (state_ == kProducingFrame) |
| + state_ = kIdle; |
| } |
| void LayerHost::Upload(Layer* layer) { |
| + if (!surface_holder_.IsReadyForFrame()) { |
| + if (state_ == kProducingFrame) |
|
esprehn
2014/11/21 19:34:45
What schedules the eventual upload if it wasn't re
abarth-chromium
2014/11/21 20:01:17
The OnSurfaceIdAvailable callback is called whenev
|
| + state_ = kWaitingForSurfaceToUploadFrame; |
| + return; |
| + } |
| + |
| gfx::Size size = layer->size(); |
| surface_holder_.SetSize(size); |