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 "services/ui/common/gpu_service.h" | 5 #include "services/ui/common/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 "base/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 CHECK(io_thread_.StartWithOptions(thread_options)); | 45 CHECK(io_thread_.StartWithOptions(thread_options)); |
46 } | 46 } |
47 | 47 |
48 GpuService::~GpuService() { | 48 GpuService::~GpuService() { |
49 DCHECK(IsMainThread()); | 49 DCHECK(IsMainThread()); |
50 if (gpu_channel_) | 50 if (gpu_channel_) |
51 gpu_channel_->DestroyChannel(); | 51 gpu_channel_->DestroyChannel(); |
52 } | 52 } |
53 | 53 |
54 // static | 54 // static |
55 bool GpuService::UseChromeGpuCommandBuffer() { | |
56 // TODO(penghuang): Kludge: Running with Chrome GPU command buffer by default | |
57 // breaks unit tests on Windows | |
58 #if defined(OS_WIN) | |
59 return false; | |
60 #else | |
61 return !base::CommandLine::ForCurrentProcess()->HasSwitch( | |
62 switches::kUseMojoGpuCommandBufferInMus); | |
63 #endif | |
64 } | |
65 | |
66 // static | |
67 void GpuService::Initialize(shell::Connector* connector) { | 55 void GpuService::Initialize(shell::Connector* connector) { |
68 DCHECK(!g_gpu_service); | 56 DCHECK(!g_gpu_service); |
69 g_gpu_service = new GpuService(connector); | 57 g_gpu_service = new GpuService(connector); |
70 } | 58 } |
71 | 59 |
72 // static | 60 // static |
73 void GpuService::Terminate() { | 61 void GpuService::Terminate() { |
74 DCHECK(g_gpu_service); | 62 DCHECK(g_gpu_service); |
75 delete g_gpu_service; | 63 delete g_gpu_service; |
76 g_gpu_service = nullptr; | 64 g_gpu_service = nullptr; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 MojoResult result = mojo::UnwrapSharedMemoryHandle( | 232 MojoResult result = mojo::UnwrapSharedMemoryHandle( |
245 std::move(handle), &platform_handle, &shared_memory_size, &readonly); | 233 std::move(handle), &platform_handle, &shared_memory_size, &readonly); |
246 if (result != MOJO_RESULT_OK) | 234 if (result != MOJO_RESULT_OK) |
247 return nullptr; | 235 return nullptr; |
248 DCHECK_EQ(shared_memory_size, size); | 236 DCHECK_EQ(shared_memory_size, size); |
249 | 237 |
250 return base::MakeUnique<base::SharedMemory>(platform_handle, readonly); | 238 return base::MakeUnique<base::SharedMemory>(platform_handle, readonly); |
251 } | 239 } |
252 | 240 |
253 } // namespace ui | 241 } // namespace ui |
OLD | NEW |