| 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 auto compositor_frame_sink = window_port->RequestCompositorFrameSink( |
| 30 ui::mojom::CompositorFrameSinkType::DEFAULT, | |
| 31 gpu_->CreateContextProvider(std::move(gpu_channel)), | 30 gpu_->CreateContextProvider(std::move(gpu_channel)), |
| 32 gpu_->gpu_memory_buffer_manager()); | 31 gpu_->gpu_memory_buffer_manager()); |
| 33 compositor->SetCompositorFrameSink(std::move(compositor_frame_sink)); | 32 compositor->SetCompositorFrameSink(std::move(compositor_frame_sink)); |
| 34 } | 33 } |
| 35 | 34 |
| 36 void MusContextFactory::CreateCompositorFrameSink( | 35 void MusContextFactory::CreateCompositorFrameSink( |
| 37 base::WeakPtr<ui::Compositor> compositor) { | 36 base::WeakPtr<ui::Compositor> compositor) { |
| 38 gpu_->EstablishGpuChannel( | 37 gpu_->EstablishGpuChannel( |
| 39 base::Bind(&MusContextFactory::OnEstablishedGpuChannel, | 38 base::Bind(&MusContextFactory::OnEstablishedGpuChannel, |
| 40 weak_ptr_factory_.GetWeakPtr(), compositor)); | 39 weak_ptr_factory_.GetWeakPtr(), compositor)); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 62 | 61 |
| 63 gpu::GpuMemoryBufferManager* MusContextFactory::GetGpuMemoryBufferManager() { | 62 gpu::GpuMemoryBufferManager* MusContextFactory::GetGpuMemoryBufferManager() { |
| 64 return gpu_->gpu_memory_buffer_manager(); | 63 return gpu_->gpu_memory_buffer_manager(); |
| 65 } | 64 } |
| 66 | 65 |
| 67 cc::TaskGraphRunner* MusContextFactory::GetTaskGraphRunner() { | 66 cc::TaskGraphRunner* MusContextFactory::GetTaskGraphRunner() { |
| 68 return raster_thread_helper_.task_graph_runner(); | 67 return raster_thread_helper_.task_graph_runner(); |
| 69 } | 68 } |
| 70 | 69 |
| 71 } // namespace aura | 70 } // namespace aura |
| OLD | NEW |