OLD | NEW |
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 "examples/ui/noodles/rasterizer.h" | 5 #include "examples/ui/noodles/rasterizer.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "examples/ui/noodles/frame.h" | 9 #include "examples/ui/noodles/frame.h" |
10 #include "third_party/skia/include/core/SkCanvas.h" | 10 #include "third_party/skia/include/core/SkCanvas.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 : gl_context_owner_(connector.get()), | 21 : gl_context_owner_(connector.get()), |
22 ganesh_context_(gl_context_owner_.context()), | 22 ganesh_context_(gl_context_owner_.context()), |
23 ganesh_renderer_(&ganesh_context_), | 23 ganesh_renderer_(&ganesh_context_), |
24 scene_(scene.Pass()) {} | 24 scene_(scene.Pass()) {} |
25 | 25 |
26 Rasterizer::~Rasterizer() {} | 26 Rasterizer::~Rasterizer() {} |
27 | 27 |
28 void Rasterizer::PublishFrame(std::unique_ptr<Frame> frame) { | 28 void Rasterizer::PublishFrame(std::unique_ptr<Frame> frame) { |
29 DCHECK(frame); | 29 DCHECK(frame); |
30 | 30 |
31 mojo::Rect bounds; | 31 mojo::RectF bounds; |
32 bounds.width = frame->size().width; | 32 bounds.width = frame->size().width; |
33 bounds.height = frame->size().height; | 33 bounds.height = frame->size().height; |
34 | 34 |
35 auto update = mojo::gfx::composition::SceneUpdate::New(); | 35 auto update = mojo::gfx::composition::SceneUpdate::New(); |
36 mojo::gfx::composition::ResourcePtr content_resource = | 36 mojo::gfx::composition::ResourcePtr content_resource = |
37 ganesh_renderer_.DrawCanvas( | 37 ganesh_renderer_.DrawCanvas( |
38 frame->size(), | 38 frame->size(), |
39 base::Bind(&Frame::Paint, base::Unretained(frame.get()))); | 39 base::Bind(&Frame::Paint, base::Unretained(frame.get()))); |
40 DCHECK(content_resource); | 40 DCHECK(content_resource); |
41 update->resources.insert(kContentImageResourceId, content_resource.Pass()); | 41 update->resources.insert(kContentImageResourceId, content_resource.Pass()); |
42 | 42 |
43 auto root_node = mojo::gfx::composition::Node::New(); | 43 auto root_node = mojo::gfx::composition::Node::New(); |
44 root_node->op = mojo::gfx::composition::NodeOp::New(); | 44 root_node->op = mojo::gfx::composition::NodeOp::New(); |
45 root_node->op->set_image(mojo::gfx::composition::ImageNodeOp::New()); | 45 root_node->op->set_image(mojo::gfx::composition::ImageNodeOp::New()); |
46 root_node->op->get_image()->content_rect = bounds.Clone(); | 46 root_node->op->get_image()->content_rect = bounds.Clone(); |
47 root_node->op->get_image()->image_resource_id = kContentImageResourceId; | 47 root_node->op->get_image()->image_resource_id = kContentImageResourceId; |
48 update->nodes.insert(kRootNodeId, root_node.Pass()); | 48 update->nodes.insert(kRootNodeId, root_node.Pass()); |
49 | 49 |
50 scene_->Update(update.Pass()); | 50 scene_->Update(update.Pass()); |
51 scene_->Publish(frame->TakeSceneMetadata()); | 51 scene_->Publish(frame->TakeSceneMetadata()); |
52 } | 52 } |
53 | 53 |
54 } // namespace examples | 54 } // namespace examples |
OLD | NEW |