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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | examples/shadows/shadows_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "apps/moterm/moterm_view.h" 5 #include "apps/moterm/moterm_view.h"
6 6
7 #ifndef GL_GLEXT_PROTOTYPES 7 #ifndef GL_GLEXT_PROTOTYPES
8 #define GL_GLEXT_PROTOTYPES 8 #define GL_GLEXT_PROTOTYPES
9 #endif 9 #endif
10 10
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 } 221 }
222 222
223 void MotermView::OnDraw(const mojo::gfx::composition::FrameInfo& frame_info, 223 void MotermView::OnDraw(const mojo::gfx::composition::FrameInfo& frame_info,
224 const base::TimeDelta& time_delta) { 224 const base::TimeDelta& time_delta) {
225 if (!properties()) 225 if (!properties())
226 return; 226 return;
227 227
228 // TODO(vtl): Draw only the dirty region(s)? 228 // TODO(vtl): Draw only the dirty region(s)?
229 model_state_changes_.Reset(); 229 model_state_changes_.Reset();
230 230
231 auto update = mojo::gfx::composition::SceneUpdate::New();
232
231 const mojo::Size& size = *properties()->view_layout->size; 233 const mojo::Size& size = *properties()->view_layout->size;
232 mojo::RectF bounds; 234 if (size.width > 0 && size.height > 0) {
233 bounds.width = size.width; 235 mojo::RectF bounds;
234 bounds.height = size.height; 236 bounds.width = size.width;
237 bounds.height = size.height;
235 238
236 auto update = mojo::gfx::composition::SceneUpdate::New(); 239 mojo::gfx::composition::ResourcePtr moterm_resource =
237 mojo::gfx::composition::ResourcePtr moterm_resource = 240 ganesh_renderer()->DrawCanvas(
238 ganesh_renderer()->DrawCanvas( 241 size, base::Bind(&MotermView::DrawContent, base::Unretained(this)));
239 size, base::Bind(&MotermView::DrawContent, base::Unretained(this))); 242 DCHECK(moterm_resource);
240 DCHECK(moterm_resource); 243 update->resources.insert(kMotermImageResourceId, moterm_resource.Pass());
241 update->resources.insert(kMotermImageResourceId, moterm_resource.Pass());
242 244
243 auto root_node = mojo::gfx::composition::Node::New(); 245 auto root_node = mojo::gfx::composition::Node::New();
244 root_node->hit_test_behavior = mojo::gfx::composition::HitTestBehavior::New(); 246 root_node->hit_test_behavior =
245 root_node->op = mojo::gfx::composition::NodeOp::New(); 247 mojo::gfx::composition::HitTestBehavior::New();
246 root_node->op->set_image(mojo::gfx::composition::ImageNodeOp::New()); 248 root_node->op = mojo::gfx::composition::NodeOp::New();
247 root_node->op->get_image()->content_rect = bounds.Clone(); 249 root_node->op->set_image(mojo::gfx::composition::ImageNodeOp::New());
248 root_node->op->get_image()->image_resource_id = kMotermImageResourceId; 250 root_node->op->get_image()->content_rect = bounds.Clone();
249 update->nodes.insert(kRootNodeId, root_node.Pass()); 251 root_node->op->get_image()->image_resource_id = kMotermImageResourceId;
252 update->nodes.insert(kRootNodeId, root_node.Pass());
253 } else {
254 auto root_node = mojo::gfx::composition::Node::New();
255 update->nodes.insert(kRootNodeId, root_node.Pass());
256 }
250 257
251 scene()->Update(update.Pass()); 258 scene()->Update(update.Pass());
252 259
253 auto metadata = mojo::gfx::composition::SceneMetadata::New(); 260 auto metadata = mojo::gfx::composition::SceneMetadata::New();
254 metadata->version = scene_version(); 261 metadata->version = scene_version();
255 metadata->presentation_time = frame_info.presentation_time; 262 metadata->presentation_time = frame_info.presentation_time;
256 scene()->Publish(metadata.Pass()); 263 scene()->Publish(metadata.Pass());
257 } 264 }
258 265
259 void MotermView::DrawContent(SkCanvas* canvas) { 266 void MotermView::DrawContent(SkCanvas* canvas) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 329
323 void MotermView::OnKeyPressed(mojo::EventPtr key_event) { 330 void MotermView::OnKeyPressed(mojo::EventPtr key_event) {
324 std::string input_sequence = 331 std::string input_sequence =
325 GetInputSequenceForKeyPressedEvent(*key_event, keypad_application_mode_); 332 GetInputSequenceForKeyPressedEvent(*key_event, keypad_application_mode_);
326 if (input_sequence.empty()) 333 if (input_sequence.empty())
327 return; 334 return;
328 335
329 if (driver_) 336 if (driver_)
330 driver_->SendData(input_sequence.data(), input_sequence.size()); 337 driver_->SendData(input_sequence.data(), input_sequence.size());
331 } 338 }
OLDNEW
« 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