Merge pull request #1384 from jamesr/empty_texture_crash

Empty texture crash
This commit is contained in:
James Robinson 2015-09-28 18:23:23 -07:00
commit aa60ff399e
4 changed files with 19 additions and 0 deletions

View File

@ -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());
}

View File

@ -24,6 +24,8 @@ scoped_ptr<mojo::GLTexture> 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));

View File

@ -45,6 +45,10 @@ PassRefPtr<SkPicture> TextureLayer::RecordPicture() {
return adoptRef(recorder.endRecordingAsPicture());
}
bool TextureLayer::HaveTexture() const {
return texture_;
}
scoped_ptr<mojo::GLTexture> TextureLayer::GetTexture() {
return texture_.Pass();
}

View File

@ -24,6 +24,7 @@ class TextureLayer : public base::RefCounted<TextureLayer> {
void SetSize(const gfx::Size& size);
void Display();
bool HaveTexture() const;
scoped_ptr<mojo::GLTexture> GetTexture();
const gfx::Size& size() const { return size_; }