Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Unified Diff: apps/moterm/moterm_view.cc

Issue 1868093002: Mozart: Fix 0x0 crashes in example views. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | examples/shadows/shadows_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: apps/moterm/moterm_view.cc
diff --git a/apps/moterm/moterm_view.cc b/apps/moterm/moterm_view.cc
index 4bf6abe43b6b7f5876fe5e9fd6c7f463391dcc8f..f248b9196513c207c5bdacf6d97f162ceda4f7b5 100644
--- a/apps/moterm/moterm_view.cc
+++ b/apps/moterm/moterm_view.cc
@@ -228,25 +228,32 @@ void MotermView::OnDraw(const mojo::gfx::composition::FrameInfo& frame_info,
// TODO(vtl): Draw only the dirty region(s)?
model_state_changes_.Reset();
- const mojo::Size& size = *properties()->view_layout->size;
- mojo::RectF bounds;
- bounds.width = size.width;
- bounds.height = size.height;
-
auto update = mojo::gfx::composition::SceneUpdate::New();
- mojo::gfx::composition::ResourcePtr moterm_resource =
- ganesh_renderer()->DrawCanvas(
- size, base::Bind(&MotermView::DrawContent, base::Unretained(this)));
- DCHECK(moterm_resource);
- update->resources.insert(kMotermImageResourceId, moterm_resource.Pass());
-
- auto root_node = mojo::gfx::composition::Node::New();
- root_node->hit_test_behavior = mojo::gfx::composition::HitTestBehavior::New();
- root_node->op = mojo::gfx::composition::NodeOp::New();
- root_node->op->set_image(mojo::gfx::composition::ImageNodeOp::New());
- root_node->op->get_image()->content_rect = bounds.Clone();
- root_node->op->get_image()->image_resource_id = kMotermImageResourceId;
- update->nodes.insert(kRootNodeId, root_node.Pass());
+
+ const mojo::Size& size = *properties()->view_layout->size;
+ if (size.width > 0 && size.height > 0) {
+ mojo::RectF bounds;
+ bounds.width = size.width;
+ bounds.height = size.height;
+
+ mojo::gfx::composition::ResourcePtr moterm_resource =
+ ganesh_renderer()->DrawCanvas(
+ size, base::Bind(&MotermView::DrawContent, base::Unretained(this)));
+ DCHECK(moterm_resource);
+ update->resources.insert(kMotermImageResourceId, moterm_resource.Pass());
+
+ auto root_node = mojo::gfx::composition::Node::New();
+ root_node->hit_test_behavior =
+ mojo::gfx::composition::HitTestBehavior::New();
+ root_node->op = mojo::gfx::composition::NodeOp::New();
+ root_node->op->set_image(mojo::gfx::composition::ImageNodeOp::New());
+ root_node->op->get_image()->content_rect = bounds.Clone();
+ root_node->op->get_image()->image_resource_id = kMotermImageResourceId;
+ update->nodes.insert(kRootNodeId, root_node.Pass());
+ } else {
+ auto root_node = mojo::gfx::composition::Node::New();
+ update->nodes.insert(kRootNodeId, root_node.Pass());
+ }
scene()->Update(update.Pass());
« no previous file with comments | « no previous file | examples/shadows/shadows_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698