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

Unified Diff: examples/ui/noodles/rasterizer.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 | « examples/shadows/shadows_view.cc ('k') | examples/ui/pdf_viewer/pdf_viewer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: examples/ui/noodles/rasterizer.cc
diff --git a/examples/ui/noodles/rasterizer.cc b/examples/ui/noodles/rasterizer.cc
index 4ec1d307ea06ba76470061d481a9557540f44412..4bd9095d24b15e2250aaefb31028fe7c70e734ce 100644
--- a/examples/ui/noodles/rasterizer.cc
+++ b/examples/ui/noodles/rasterizer.cc
@@ -28,24 +28,30 @@ Rasterizer::~Rasterizer() {}
void Rasterizer::PublishFrame(std::unique_ptr<Frame> frame) {
DCHECK(frame);
- mojo::RectF bounds;
- bounds.width = frame->size().width;
- bounds.height = frame->size().height;
-
auto update = mojo::gfx::composition::SceneUpdate::New();
- mojo::gfx::composition::ResourcePtr content_resource =
- ganesh_renderer_.DrawCanvas(
- frame->size(),
- base::Bind(&Frame::Paint, base::Unretained(frame.get())));
- DCHECK(content_resource);
- update->resources.insert(kContentImageResourceId, content_resource.Pass());
-
- auto root_node = mojo::gfx::composition::Node::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 = kContentImageResourceId;
- update->nodes.insert(kRootNodeId, root_node.Pass());
+
+ if (frame->size().width > 0 && frame->size().height > 0) {
+ mojo::RectF bounds;
+ bounds.width = frame->size().width;
+ bounds.height = frame->size().height;
+
+ mojo::gfx::composition::ResourcePtr content_resource =
+ ganesh_renderer_.DrawCanvas(
+ frame->size(),
+ base::Bind(&Frame::Paint, base::Unretained(frame.get())));
+ DCHECK(content_resource);
+ update->resources.insert(kContentImageResourceId, content_resource.Pass());
+
+ auto root_node = mojo::gfx::composition::Node::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 = kContentImageResourceId;
+ 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());
scene_->Publish(frame->TakeSceneMetadata());
« no previous file with comments | « examples/shadows/shadows_view.cc ('k') | examples/ui/pdf_viewer/pdf_viewer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698