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 |
55 void GpuService::Initialize(shell::Connector* connector) { | 67 void GpuService::Initialize(shell::Connector* connector) { |
56 DCHECK(!g_gpu_service); | 68 DCHECK(!g_gpu_service); |
57 g_gpu_service = new GpuService(connector); | 69 g_gpu_service = new GpuService(connector); |
58 } | 70 } |
59 | 71 |
60 // static | 72 // static |
61 void GpuService::Terminate() { | 73 void GpuService::Terminate() { |
62 DCHECK(g_gpu_service); | 74 DCHECK(g_gpu_service); |
63 delete g_gpu_service; | 75 delete g_gpu_service; |
64 g_gpu_service = nullptr; | 76 g_gpu_service = nullptr; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 MojoResult result = mojo::UnwrapSharedMemoryHandle( | 244 MojoResult result = mojo::UnwrapSharedMemoryHandle( |
233 std::move(handle), &platform_handle, &shared_memory_size, &readonly); | 245 std::move(handle), &platform_handle, &shared_memory_size, &readonly); |
234 if (result != MOJO_RESULT_OK) | 246 if (result != MOJO_RESULT_OK) |
235 return nullptr; | 247 return nullptr; |
236 DCHECK_EQ(shared_memory_size, size); | 248 DCHECK_EQ(shared_memory_size, size); |
237 | 249 |
238 return base::MakeUnique<base::SharedMemory>(platform_handle, readonly); | 250 return base::MakeUnique<base::SharedMemory>(platform_handle, readonly); |
239 } | 251 } |
240 | 252 |
241 } // namespace ui | 253 } // namespace ui |
OLD | NEW |