diff --git a/services/sky/compositor/layer_host.cc b/services/sky/compositor/layer_host.cc index f8bfb119fe3..a12f165e423 100644 --- a/services/sky/compositor/layer_host.cc +++ b/services/sky/compositor/layer_host.cc @@ -83,6 +83,18 @@ void LayerHost::BeginFrame() { root_layer_->Display(); } + // We may have culled the root layer down to nothing which is equivalent to + // the empty size case above. + // + // TODO(jamesr): This needs to have proper flow control as well to avoid + // spinning when we have nothing to draw. + if (!root_layer_->HaveTexture()) { + base::MessageLoop::current()->PostTask( + FROM_HERE, + base::Bind(&LayerHost::DidCompleteFrame, weak_factory_.GetWeakPtr())); + return; + } + Upload(root_layer_.get()); } diff --git a/services/sky/compositor/rasterizer_ganesh.cc b/services/sky/compositor/rasterizer_ganesh.cc index d5d0e6f2f7a..1d660bee4bb 100644 --- a/services/sky/compositor/rasterizer_ganesh.cc +++ b/services/sky/compositor/rasterizer_ganesh.cc @@ -24,6 +24,8 @@ scoped_ptr RasterizerGanesh::Rasterize(SkPicture* picture) { SkRect cull_rect = picture->cullRect(); gfx::Size size(cull_rect.width(), cull_rect.height()); + if (size.IsEmpty()) + return nullptr; mojo::GaneshSurface surface(host_->ganesh_context(), host_->resource_manager()->CreateTexture(size)); diff --git a/services/sky/compositor/texture_layer.cc b/services/sky/compositor/texture_layer.cc index fc1d5f885cc..134fcf37aca 100644 --- a/services/sky/compositor/texture_layer.cc +++ b/services/sky/compositor/texture_layer.cc @@ -45,6 +45,10 @@ PassRefPtr TextureLayer::RecordPicture() { return adoptRef(recorder.endRecordingAsPicture()); } +bool TextureLayer::HaveTexture() const { + return texture_; +} + scoped_ptr TextureLayer::GetTexture() { return texture_.Pass(); } diff --git a/services/sky/compositor/texture_layer.h b/services/sky/compositor/texture_layer.h index 0bee97cf75a..306d1c8f0ad 100644 --- a/services/sky/compositor/texture_layer.h +++ b/services/sky/compositor/texture_layer.h @@ -24,6 +24,7 @@ class TextureLayer : public base::RefCounted { void SetSize(const gfx::Size& size); void Display(); + bool HaveTexture() const; scoped_ptr GetTexture(); const gfx::Size& size() const { return size_; }