| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/mus/public/cpp/lib/gpu_service.h" | 5 #include "components/mus/public/cpp/lib/gpu_service.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
| 9 #include "components/mus/common/gpu_type_converters.h" | 9 #include "components/mus/common/gpu_type_converters.h" |
| 10 #include "components/mus/common/mojo_gpu_memory_buffer_manager.h" |
| 10 #include "components/mus/common/switches.h" | 11 #include "components/mus/common/switches.h" |
| 11 #include "components/mus/public/cpp/lib/gpu_memory_buffer_manager_mus.h" | |
| 12 #include "components/mus/public/interfaces/gpu_service.mojom.h" | 12 #include "components/mus/public/interfaces/gpu_service.mojom.h" |
| 13 #include "services/shell/public/cpp/connector.h" | 13 #include "services/shell/public/cpp/connector.h" |
| 14 | 14 |
| 15 namespace mus { | 15 namespace mus { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 void GpuChannelEstablishCallback(int* client_id_out, | 19 void GpuChannelEstablishCallback(int* client_id_out, |
| 20 IPC::ChannelHandle* channel_handle_out, | 20 IPC::ChannelHandle* channel_handle_out, |
| 21 gpu::GPUInfo* gpu_info_out, | 21 gpu::GPUInfo* gpu_info_out, |
| 22 int client_id, | 22 int client_id, |
| 23 mus::mojom::ChannelHandlePtr channel_handle, | 23 mus::mojom::ChannelHandlePtr channel_handle, |
| 24 mus::mojom::GpuInfoPtr gpu_info) { | 24 mus::mojom::GpuInfoPtr gpu_info) { |
| 25 *client_id_out = client_id; | 25 *client_id_out = client_id; |
| 26 *channel_handle_out = channel_handle.To<IPC::ChannelHandle>(); | 26 *channel_handle_out = channel_handle.To<IPC::ChannelHandle>(); |
| 27 // TODO(penghuang): Get the gpu info. | 27 // TODO(penghuang): Get the gpu info. |
| 28 } | 28 } |
| 29 } | 29 } |
| 30 | 30 |
| 31 GpuService::GpuService() | 31 GpuService::GpuService() |
| 32 : main_message_loop_(base::MessageLoop::current()), | 32 : main_message_loop_(base::MessageLoop::current()), |
| 33 shutdown_event_(false, false), | 33 shutdown_event_(false, false), |
| 34 io_thread_("GPUIOThread"), | 34 io_thread_("GPUIOThread"), |
| 35 gpu_memory_buffer_manager_(new mus::GpuMemoryBufferManagerMus) { | 35 gpu_memory_buffer_manager_(new MojoGpuMemoryBufferManager) { |
| 36 base::Thread::Options thread_options(base::MessageLoop::TYPE_IO, 0); | 36 base::Thread::Options thread_options(base::MessageLoop::TYPE_IO, 0); |
| 37 thread_options.priority = base::ThreadPriority::NORMAL; | 37 thread_options.priority = base::ThreadPriority::NORMAL; |
| 38 CHECK(io_thread_.StartWithOptions(thread_options)); | 38 CHECK(io_thread_.StartWithOptions(thread_options)); |
| 39 } | 39 } |
| 40 | 40 |
| 41 GpuService::~GpuService() {} | 41 GpuService::~GpuService() {} |
| 42 | 42 |
| 43 // static | 43 // static |
| 44 bool GpuService::UseChromeGpuCommandBuffer() { | 44 bool GpuService::UseChromeGpuCommandBuffer() { |
| 45 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 45 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 92 |
| 93 std::unique_ptr<base::SharedMemory> GpuService::AllocateSharedMemory( | 93 std::unique_ptr<base::SharedMemory> GpuService::AllocateSharedMemory( |
| 94 size_t size) { | 94 size_t size) { |
| 95 std::unique_ptr<base::SharedMemory> shm(new base::SharedMemory()); | 95 std::unique_ptr<base::SharedMemory> shm(new base::SharedMemory()); |
| 96 if (!shm->CreateAnonymous(size)) | 96 if (!shm->CreateAnonymous(size)) |
| 97 return std::unique_ptr<base::SharedMemory>(); | 97 return std::unique_ptr<base::SharedMemory>(); |
| 98 return shm; | 98 return shm; |
| 99 } | 99 } |
| 100 | 100 |
| 101 } // namespace mus | 101 } // namespace mus |
| OLD | NEW |