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/noodles_view.h" | 5 #include "examples/ui/noodles/noodles_view.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 | 8 |
9 #include <cstdlib> | 9 #include <cstdlib> |
10 #include <utility> | 10 #include <utility> |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 if (i == 0u) | 43 if (i == 0u) |
44 path->moveTo(x, y); | 44 path->moveTo(x, y); |
45 else | 45 else |
46 path->lineTo(x, y); | 46 path->lineTo(x, y); |
47 } | 47 } |
48 path->close(); | 48 path->close(); |
49 } | 49 } |
50 } // namespace | 50 } // namespace |
51 | 51 |
52 NoodlesView::NoodlesView( | 52 NoodlesView::NoodlesView( |
53 mojo::ApplicationImpl* app_impl, | 53 mojo::InterfaceHandle<mojo::ApplicationConnector> app_connector, |
54 mojo::InterfaceRequest<mojo::ui::ViewOwner> view_owner_request) | 54 mojo::InterfaceRequest<mojo::ui::ViewOwner> view_owner_request) |
55 : BaseView(app_impl, view_owner_request.Pass(), "Noodles"), | 55 : BaseView(app_connector.Pass(), view_owner_request.Pass(), "Noodles"), |
56 choreographer_(scene(), this), | 56 choreographer_(scene(), this), |
57 frame_queue_(std::make_shared<FrameQueue>()), | 57 frame_queue_(std::make_shared<FrameQueue>()), |
58 rasterizer_delegate_( | 58 rasterizer_delegate_( |
59 make_scoped_ptr(new RasterizerDelegate(frame_queue_))) { | 59 make_scoped_ptr(new RasterizerDelegate(frame_queue_))) { |
60 base::Thread::Options options; | 60 base::Thread::Options options; |
61 options.message_pump_factory = base::Bind(&CreateMessagePumpMojo); | 61 options.message_pump_factory = base::Bind(&CreateMessagePumpMojo); |
62 | 62 |
63 rasterizer_thread_.reset(new base::Thread("noodles_rasterizer")); | 63 rasterizer_thread_.reset(new base::Thread("noodles_rasterizer")); |
64 rasterizer_thread_->StartWithOptions(options); | 64 rasterizer_thread_->StartWithOptions(options); |
65 rasterizer_task_runner_ = rasterizer_thread_->message_loop()->task_runner(); | 65 rasterizer_task_runner_ = rasterizer_thread_->message_loop()->task_runner(); |
66 | 66 |
67 rasterizer_task_runner_->PostTask( | 67 rasterizer_task_runner_->PostTask( |
68 FROM_HERE, | 68 FROM_HERE, base::Bind(&RasterizerDelegate::CreateRasterizer, |
69 base::Bind( | 69 base::Unretained(rasterizer_delegate_.get()), |
70 &RasterizerDelegate::CreateRasterizer, | 70 base::Passed(mojo::DuplicateApplicationConnector( |
71 base::Unretained(rasterizer_delegate_.get()), | 71 BaseView::app_connector())), |
72 base::Passed(mojo::CreateApplicationConnector(app_impl->shell())), | 72 base::Passed(TakeScene().PassInterfaceHandle()))); |
73 base::Passed(TakeScene().PassInterfaceHandle()))); | |
74 } | 73 } |
75 | 74 |
76 NoodlesView::~NoodlesView() { | 75 NoodlesView::~NoodlesView() { |
77 // Ensure destruction happens on the correct thread. | 76 // Ensure destruction happens on the correct thread. |
78 rasterizer_task_runner_->PostTask( | 77 rasterizer_task_runner_->PostTask( |
79 FROM_HERE, base::Bind(&Drop<RasterizerDelegate>, | 78 FROM_HERE, base::Bind(&Drop<RasterizerDelegate>, |
80 base::Passed(&rasterizer_delegate_))); | 79 base::Passed(&rasterizer_delegate_))); |
81 } | 80 } |
82 | 81 |
83 void NoodlesView::OnPropertiesChanged( | 82 void NoodlesView::OnPropertiesChanged( |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 mojo::gfx::composition::ScenePtr::Create(std::move(scene_info)))); | 175 mojo::gfx::composition::ScenePtr::Create(std::move(scene_info)))); |
177 } | 176 } |
178 | 177 |
179 void NoodlesView::RasterizerDelegate::PublishNextFrame() { | 178 void NoodlesView::RasterizerDelegate::PublishNextFrame() { |
180 std::unique_ptr<Frame> frame(frame_queue_->TakeFrame()); | 179 std::unique_ptr<Frame> frame(frame_queue_->TakeFrame()); |
181 DCHECK(frame); | 180 DCHECK(frame); |
182 rasterizer_->PublishFrame(std::move(frame)); | 181 rasterizer_->PublishFrame(std::move(frame)); |
183 } | 182 } |
184 | 183 |
185 } // namespace examples | 184 } // namespace examples |
OLD | NEW |