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> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "examples/ui/noodles/frame.h" | 15 #include "examples/ui/noodles/frame.h" |
16 #include "examples/ui/noodles/rasterizer.h" | 16 #include "examples/ui/noodles/rasterizer.h" |
| 17 #include "mojo/public/cpp/application/connect.h" |
17 #include "third_party/skia/include/core/SkCanvas.h" | 18 #include "third_party/skia/include/core/SkCanvas.h" |
18 #include "third_party/skia/include/core/SkColor.h" | 19 #include "third_party/skia/include/core/SkColor.h" |
19 #include "third_party/skia/include/core/SkPath.h" | 20 #include "third_party/skia/include/core/SkPath.h" |
20 #include "third_party/skia/include/core/SkPicture.h" | 21 #include "third_party/skia/include/core/SkPicture.h" |
21 #include "third_party/skia/include/core/SkPictureRecorder.h" | 22 #include "third_party/skia/include/core/SkPictureRecorder.h" |
22 | 23 |
23 namespace examples { | 24 namespace examples { |
24 | 25 |
25 namespace { | 26 namespace { |
26 constexpr double kSecondsBetweenChanges = 10.0; | 27 constexpr double kSecondsBetweenChanges = 10.0; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 make_scoped_ptr(new RasterizerDelegate(frame_queue_))) { | 59 make_scoped_ptr(new RasterizerDelegate(frame_queue_))) { |
59 base::Thread::Options options; | 60 base::Thread::Options options; |
60 options.message_pump_factory = base::Bind(&CreateMessagePumpMojo); | 61 options.message_pump_factory = base::Bind(&CreateMessagePumpMojo); |
61 | 62 |
62 rasterizer_thread_.reset(new base::Thread("noodles_rasterizer")); | 63 rasterizer_thread_.reset(new base::Thread("noodles_rasterizer")); |
63 rasterizer_thread_->StartWithOptions(options); | 64 rasterizer_thread_->StartWithOptions(options); |
64 rasterizer_task_runner_ = rasterizer_thread_->message_loop()->task_runner(); | 65 rasterizer_task_runner_ = rasterizer_thread_->message_loop()->task_runner(); |
65 | 66 |
66 rasterizer_task_runner_->PostTask( | 67 rasterizer_task_runner_->PostTask( |
67 FROM_HERE, | 68 FROM_HERE, |
68 base::Bind(&RasterizerDelegate::CreateRasterizer, | 69 base::Bind( |
69 base::Unretained(rasterizer_delegate_.get()), | 70 &RasterizerDelegate::CreateRasterizer, |
70 base::Passed(app_impl->CreateApplicationConnector()), | 71 base::Unretained(rasterizer_delegate_.get()), |
71 base::Passed(TakeScene().PassInterfaceHandle()))); | 72 base::Passed(mojo::CreateApplicationConnector(app_impl->shell())), |
| 73 base::Passed(TakeScene().PassInterfaceHandle()))); |
72 } | 74 } |
73 | 75 |
74 NoodlesView::~NoodlesView() { | 76 NoodlesView::~NoodlesView() { |
75 // Ensure destruction happens on the correct thread. | 77 // Ensure destruction happens on the correct thread. |
76 rasterizer_task_runner_->PostTask( | 78 rasterizer_task_runner_->PostTask( |
77 FROM_HERE, base::Bind(&Drop<RasterizerDelegate>, | 79 FROM_HERE, base::Bind(&Drop<RasterizerDelegate>, |
78 base::Passed(&rasterizer_delegate_))); | 80 base::Passed(&rasterizer_delegate_))); |
79 } | 81 } |
80 | 82 |
81 void NoodlesView::OnPropertiesChanged( | 83 void NoodlesView::OnPropertiesChanged( |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 mojo::gfx::composition::ScenePtr::Create(std::move(scene_info)))); | 176 mojo::gfx::composition::ScenePtr::Create(std::move(scene_info)))); |
175 } | 177 } |
176 | 178 |
177 void NoodlesView::RasterizerDelegate::PublishNextFrame() { | 179 void NoodlesView::RasterizerDelegate::PublishNextFrame() { |
178 std::unique_ptr<Frame> frame(frame_queue_->TakeFrame()); | 180 std::unique_ptr<Frame> frame(frame_queue_->TakeFrame()); |
179 DCHECK(frame); | 181 DCHECK(frame); |
180 rasterizer_->PublishFrame(std::move(frame)); | 182 rasterizer_->PublishFrame(std::move(frame)); |
181 } | 183 } |
182 | 184 |
183 } // namespace examples | 185 } // namespace examples |
OLD | NEW |