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 "services/gfx/compositor/backend/gpu_output.h" | 5 #include "services/gfx/compositor/backend/gpu_output.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "services/gfx/compositor/backend/gpu_rasterizer.h" | 13 #include "services/gfx/compositor/backend/gpu_rasterizer.h" |
14 | 14 |
15 namespace compositor { | 15 namespace compositor { |
16 | 16 |
17 template <typename T> | 17 template <typename T> |
18 static void Drop(scoped_ptr<T> ptr) {} | 18 static void Drop(scoped_ptr<T> ptr) {} |
19 | 19 |
20 static scoped_ptr<base::MessagePump> CreateMessagePumpMojo() { | 20 static scoped_ptr<base::MessagePump> CreateMessagePumpMojo() { |
21 return base::MessageLoop::CreateMessagePumpForType( | 21 return base::MessageLoop::CreateMessagePumpForType( |
22 base::MessageLoop::TYPE_DEFAULT); | 22 base::MessageLoop::TYPE_DEFAULT); |
23 } | 23 } |
24 | 24 |
25 GpuOutput::GpuOutput(mojo::ContextProviderPtr context_provider, | 25 GpuOutput::GpuOutput( |
26 const SchedulerCallbacks& scheduler_callbacks, | 26 mojo::InterfaceHandle<mojo::ContextProvider> context_provider, |
27 const base::Closure& error_callback) | 27 const SchedulerCallbacks& scheduler_callbacks, |
| 28 const base::Closure& error_callback) |
28 : frame_queue_(std::make_shared<FrameQueue>()), | 29 : frame_queue_(std::make_shared<FrameQueue>()), |
29 scheduler_(std::make_shared<VsyncScheduler>(base::MessageLoop::current() | 30 scheduler_(std::make_shared<VsyncScheduler>( |
30 ->task_runner(), | 31 base::MessageLoop::current()->task_runner(), |
31 scheduler_callbacks)), | 32 scheduler_callbacks)), |
32 rasterizer_delegate_( | 33 rasterizer_delegate_( |
33 make_scoped_ptr(new RasterizerDelegate(frame_queue_))) { | 34 make_scoped_ptr(new RasterizerDelegate(frame_queue_))) { |
34 DCHECK(context_provider); | 35 DCHECK(context_provider); |
35 | 36 |
36 base::Thread::Options options; | 37 base::Thread::Options options; |
37 options.message_pump_factory = base::Bind(&CreateMessagePumpMojo); | 38 options.message_pump_factory = base::Bind(&CreateMessagePumpMojo); |
38 | 39 |
39 rasterizer_thread_.reset(new base::Thread("gpu_rasterizer")); | 40 rasterizer_thread_.reset(new base::Thread("gpu_rasterizer")); |
40 rasterizer_thread_->StartWithOptions(options); | 41 rasterizer_thread_->StartWithOptions(options); |
41 rasterizer_task_runner_ = rasterizer_thread_->message_loop()->task_runner(); | 42 rasterizer_task_runner_ = rasterizer_thread_->message_loop()->task_runner(); |
42 | 43 |
43 rasterizer_task_runner_->PostTask( | 44 rasterizer_task_runner_->PostTask( |
44 FROM_HERE, | 45 FROM_HERE, |
45 base::Bind(&RasterizerDelegate::CreateRasterizer, | 46 base::Bind(&RasterizerDelegate::CreateRasterizer, |
46 base::Unretained(rasterizer_delegate_.get()), | 47 base::Unretained(rasterizer_delegate_.get()), |
47 base::Passed(context_provider.PassInterfaceHandle()), | 48 base::Passed(std::move(context_provider)), scheduler_, |
48 scheduler_, base::MessageLoop::current()->task_runner(), | 49 base::MessageLoop::current()->task_runner(), error_callback)); |
49 error_callback)); | |
50 } | 50 } |
51 | 51 |
52 GpuOutput::~GpuOutput() { | 52 GpuOutput::~GpuOutput() { |
53 // Ensure destruction happens on the correct thread. | 53 // Ensure destruction happens on the correct thread. |
54 rasterizer_task_runner_->PostTask( | 54 rasterizer_task_runner_->PostTask( |
55 FROM_HERE, base::Bind(&Drop<RasterizerDelegate>, | 55 FROM_HERE, base::Bind(&Drop<RasterizerDelegate>, |
56 base::Passed(&rasterizer_delegate_))); | 56 base::Passed(&rasterizer_delegate_))); |
57 } | 57 } |
58 | 58 |
59 Scheduler* GpuOutput::GetScheduler() { | 59 Scheduler* GpuOutput::GetScheduler() { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 scheduler, task_runner, error_callback)); | 103 scheduler, task_runner, error_callback)); |
104 } | 104 } |
105 | 105 |
106 void GpuOutput::RasterizerDelegate::SubmitNextFrame() { | 106 void GpuOutput::RasterizerDelegate::SubmitNextFrame() { |
107 std::shared_ptr<RenderFrame> frame(frame_queue_->TakeFrame()); | 107 std::shared_ptr<RenderFrame> frame(frame_queue_->TakeFrame()); |
108 DCHECK(frame); | 108 DCHECK(frame); |
109 rasterizer_->SubmitFrame(frame); | 109 rasterizer_->SubmitFrame(frame); |
110 } | 110 } |
111 | 111 |
112 } // namespace compositor | 112 } // namespace compositor |
OLD | NEW |