mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Merge pull request #1384 from jamesr/empty_texture_crash
Empty texture crash
This commit is contained in:
commit
aa60ff399e
@ -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());
|
||||
}
|
||||
|
||||
|
||||
@ -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));
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
@ -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_; }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user