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 "ui/aura/mus/mus_context_factory.h" | 5 #include "ui/aura/mus/mus_context_factory.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "services/ui/public/cpp/gpu/gpu.h" | 8 #include "services/ui/public/cpp/gpu/gpu.h" |
9 #include "ui/aura/mus/window_port_mus.h" | 9 #include "ui/aura/mus/window_port_mus.h" |
10 #include "ui/aura/window_tree_host.h" | 10 #include "ui/aura/window_tree_host.h" |
11 #include "ui/gl/gl_bindings.h" | 11 #include "ui/gl/gl_bindings.h" |
12 | 12 |
13 namespace aura { | 13 namespace aura { |
14 | 14 |
15 MusContextFactory::MusContextFactory(ui::Gpu* gpu) | 15 MusContextFactory::MusContextFactory(ui::Gpu* gpu) |
16 : gpu_(gpu), weak_ptr_factory_(this) {} | 16 : gpu_(gpu), weak_ptr_factory_(this) {} |
17 | 17 |
18 MusContextFactory::~MusContextFactory() {} | 18 MusContextFactory::~MusContextFactory() {} |
19 | 19 |
20 void MusContextFactory::OnEstablishedGpuChannel( | 20 void MusContextFactory::OnEstablishedGpuChannel( |
21 base::WeakPtr<ui::Compositor> compositor, | 21 base::WeakPtr<ui::Compositor> compositor, |
22 scoped_refptr<gpu::GpuChannelHost> gpu_channel) { | 22 scoped_refptr<gpu::GpuChannelHost> gpu_channel) { |
23 if (!compositor) | 23 if (!compositor) |
24 return; | 24 return; |
25 WindowTreeHost* host = | 25 WindowTreeHost* host = |
26 WindowTreeHost::GetForAcceleratedWidget(compositor->widget()); | 26 WindowTreeHost::GetForAcceleratedWidget(compositor->widget()); |
27 WindowPortMus* window_port = WindowPortMus::Get(host->window()); | 27 WindowPortMus* window_port = WindowPortMus::Get(host->window()); |
28 DCHECK(window_port); | 28 DCHECK(window_port); |
29 auto compositor_frame_sink = window_port->RequestCompositorFrameSink( | 29 window_port->RequestCompositorFrameSink( |
30 gpu_->CreateContextProvider(std::move(gpu_channel)), | 30 gpu_->CreateContextProvider(std::move(gpu_channel)), |
31 gpu_->gpu_memory_buffer_manager()); | 31 gpu_->gpu_memory_buffer_manager(), |
| 32 base::Bind(&MusContextFactory::OnCompositorFrameSinkAvailable, |
| 33 weak_ptr_factory_.GetWeakPtr(), compositor)); |
| 34 } |
| 35 |
| 36 void MusContextFactory::OnCompositorFrameSinkAvailable( |
| 37 base::WeakPtr<ui::Compositor> compositor, |
| 38 std::unique_ptr<cc::CompositorFrameSink> compositor_frame_sink) { |
| 39 if (!compositor) |
| 40 return; |
32 compositor->SetCompositorFrameSink(std::move(compositor_frame_sink)); | 41 compositor->SetCompositorFrameSink(std::move(compositor_frame_sink)); |
33 } | 42 } |
34 | 43 |
35 void MusContextFactory::CreateCompositorFrameSink( | 44 void MusContextFactory::CreateCompositorFrameSink( |
36 base::WeakPtr<ui::Compositor> compositor) { | 45 base::WeakPtr<ui::Compositor> compositor) { |
37 gpu_->EstablishGpuChannel( | 46 gpu_->EstablishGpuChannel( |
38 base::Bind(&MusContextFactory::OnEstablishedGpuChannel, | 47 base::Bind(&MusContextFactory::OnEstablishedGpuChannel, |
39 weak_ptr_factory_.GetWeakPtr(), compositor)); | 48 weak_ptr_factory_.GetWeakPtr(), compositor)); |
40 } | 49 } |
41 | 50 |
(...skipping 19 matching lines...) Expand all Loading... |
61 | 70 |
62 gpu::GpuMemoryBufferManager* MusContextFactory::GetGpuMemoryBufferManager() { | 71 gpu::GpuMemoryBufferManager* MusContextFactory::GetGpuMemoryBufferManager() { |
63 return gpu_->gpu_memory_buffer_manager(); | 72 return gpu_->gpu_memory_buffer_manager(); |
64 } | 73 } |
65 | 74 |
66 cc::TaskGraphRunner* MusContextFactory::GetTaskGraphRunner() { | 75 cc::TaskGraphRunner* MusContextFactory::GetTaskGraphRunner() { |
67 return raster_thread_helper_.task_graph_runner(); | 76 return raster_thread_helper_.task_graph_runner(); |
68 } | 77 } |
69 | 78 |
70 } // namespace aura | 79 } // namespace aura |
OLD | NEW |