Chromium Code Reviews| 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/context_provider.h" | |
| 9 #include "services/ui/public/cpp/gpu/gpu.h" | 8 #include "services/ui/public/cpp/gpu/gpu.h" |
| 10 #include "ui/aura/mus/window_port_mus.h" | 9 #include "ui/aura/mus/window_port_mus.h" |
| 11 #include "ui/aura/window_tree_host.h" | 10 #include "ui/aura/window_tree_host.h" |
| 12 #include "ui/gl/gl_bindings.h" | 11 #include "ui/gl/gl_bindings.h" |
| 13 | 12 |
| 14 namespace aura { | 13 namespace aura { |
| 15 namespace { | 14 namespace { |
|
msw
2016/12/19 21:33:33
tangential nit: remove empty anon namespace block
sadrul
2016/12/20 03:53:20
Already done (landed in crrev.com/439651)
| |
| 16 | 15 |
| 17 | 16 |
| 18 } // namespace | 17 } // namespace |
| 19 | 18 |
| 20 MusContextFactory::MusContextFactory(ui::Gpu* gpu) : gpu_(gpu) {} | 19 MusContextFactory::MusContextFactory(ui::Gpu* gpu) |
| 20 : gpu_(gpu), weak_ptr_factory_(this) {} | |
| 21 | 21 |
| 22 MusContextFactory::~MusContextFactory() {} | 22 MusContextFactory::~MusContextFactory() {} |
| 23 | 23 |
| 24 void MusContextFactory::CreateCompositorFrameSink( | 24 void MusContextFactory::OnEstablishedGpuChannel( |
| 25 base::WeakPtr<ui::Compositor> compositor) { | 25 base::WeakPtr<ui::Compositor> compositor, |
| 26 scoped_refptr<gpu::GpuChannelHost> gpu_channel) { | |
| 27 if (!compositor) | |
| 28 return; | |
| 26 WindowTreeHost* host = | 29 WindowTreeHost* host = |
| 27 WindowTreeHost::GetForAcceleratedWidget(compositor->widget()); | 30 WindowTreeHost::GetForAcceleratedWidget(compositor->widget()); |
| 28 WindowPortMus* window_port = WindowPortMus::Get(host->window()); | 31 WindowPortMus* window_port = WindowPortMus::Get(host->window()); |
| 29 DCHECK(window_port); | 32 DCHECK(window_port); |
| 30 auto compositor_frame_sink = window_port->RequestCompositorFrameSink( | 33 auto compositor_frame_sink = window_port->RequestCompositorFrameSink( |
| 31 ui::mojom::CompositorFrameSinkType::DEFAULT, | 34 ui::mojom::CompositorFrameSinkType::DEFAULT, |
| 32 make_scoped_refptr( | 35 gpu_->CreateContextProvider(std::move(gpu_channel)), |
| 33 new ui::ContextProvider(gpu_->EstablishGpuChannelSync())), | |
| 34 gpu_->gpu_memory_buffer_manager()); | 36 gpu_->gpu_memory_buffer_manager()); |
| 35 compositor->SetCompositorFrameSink(std::move(compositor_frame_sink)); | 37 compositor->SetCompositorFrameSink(std::move(compositor_frame_sink)); |
| 36 } | 38 } |
| 37 | 39 |
| 40 void MusContextFactory::CreateCompositorFrameSink( | |
| 41 base::WeakPtr<ui::Compositor> compositor) { | |
| 42 gpu_->EstablishGpuChannel( | |
| 43 base::Bind(&MusContextFactory::OnEstablishedGpuChannel, | |
| 44 weak_ptr_factory_.GetWeakPtr(), compositor)); | |
| 45 } | |
| 46 | |
| 38 scoped_refptr<cc::ContextProvider> | 47 scoped_refptr<cc::ContextProvider> |
| 39 MusContextFactory::SharedMainThreadContextProvider() { | 48 MusContextFactory::SharedMainThreadContextProvider() { |
| 40 // NOTIMPLEMENTED(); | 49 // NOTIMPLEMENTED(); |
| 41 return nullptr; | 50 return nullptr; |
| 42 } | 51 } |
| 43 | 52 |
| 44 void MusContextFactory::RemoveCompositor(ui::Compositor* compositor) { | 53 void MusContextFactory::RemoveCompositor(ui::Compositor* compositor) { |
| 45 // NOTIMPLEMENTED(); | 54 // NOTIMPLEMENTED(); |
| 46 } | 55 } |
| 47 | 56 |
| 48 bool MusContextFactory::DoesCreateTestContexts() { | 57 bool MusContextFactory::DoesCreateTestContexts() { |
| 49 return false; | 58 return false; |
| 50 } | 59 } |
| 51 | 60 |
| 52 uint32_t MusContextFactory::GetImageTextureTarget(gfx::BufferFormat format, | 61 uint32_t MusContextFactory::GetImageTextureTarget(gfx::BufferFormat format, |
| 53 gfx::BufferUsage usage) { | 62 gfx::BufferUsage usage) { |
| 54 // No GpuMemoryBuffer support, so just return GL_TEXTURE_2D. | 63 // No GpuMemoryBuffer support, so just return GL_TEXTURE_2D. |
| 55 return GL_TEXTURE_2D; | 64 return GL_TEXTURE_2D; |
| 56 } | 65 } |
| 57 | 66 |
| 58 gpu::GpuMemoryBufferManager* MusContextFactory::GetGpuMemoryBufferManager() { | 67 gpu::GpuMemoryBufferManager* MusContextFactory::GetGpuMemoryBufferManager() { |
| 59 return gpu_->gpu_memory_buffer_manager(); | 68 return gpu_->gpu_memory_buffer_manager(); |
| 60 } | 69 } |
| 61 | 70 |
| 62 cc::TaskGraphRunner* MusContextFactory::GetTaskGraphRunner() { | 71 cc::TaskGraphRunner* MusContextFactory::GetTaskGraphRunner() { |
| 63 return raster_thread_helper_.task_graph_runner(); | 72 return raster_thread_helper_.task_graph_runner(); |
| 64 } | 73 } |
| 65 | 74 |
| 66 } // namespace aura | 75 } // namespace aura |
| OLD | NEW |