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/gpu/gpu_service.h" | 5 #include "services/ui/gpu/gpu_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/crash_logging.h" | 8 #include "base/debug/crash_logging.h" |
9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
| 10 #include "base/message_loop/message_loop.h" |
10 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
11 #include "build/build_config.h" | 12 #include "build/build_config.h" |
12 #include "cc/output/in_process_context_provider.h" | 13 #include "cc/output/in_process_context_provider.h" |
13 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" | 14 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" |
14 #include "gpu/command_buffer/service/gpu_switches.h" | 15 #include "gpu/command_buffer/service/gpu_switches.h" |
15 #include "gpu/command_buffer/service/sync_point_manager.h" | 16 #include "gpu/command_buffer/service/sync_point_manager.h" |
16 #include "gpu/config/gpu_info_collector.h" | 17 #include "gpu/config/gpu_info_collector.h" |
17 #include "gpu/config/gpu_switches.h" | 18 #include "gpu/config/gpu_switches.h" |
18 #include "gpu/config/gpu_util.h" | 19 #include "gpu/config/gpu_util.h" |
19 #include "gpu/ipc/common/gpu_memory_buffer_support.h" | 20 #include "gpu/ipc/common/gpu_memory_buffer_support.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 void GpuService::GetVideoMemoryUsageStats( | 136 void GpuService::GetVideoMemoryUsageStats( |
136 const GetVideoMemoryUsageStatsCallback& callback) { | 137 const GetVideoMemoryUsageStatsCallback& callback) { |
137 gpu::VideoMemoryUsageStats video_memory_usage_stats; | 138 gpu::VideoMemoryUsageStats video_memory_usage_stats; |
138 if (gpu_channel_manager_) { | 139 if (gpu_channel_manager_) { |
139 gpu_channel_manager_->gpu_memory_manager()->GetVideoMemoryUsageStats( | 140 gpu_channel_manager_->gpu_memory_manager()->GetVideoMemoryUsageStats( |
140 &video_memory_usage_stats); | 141 &video_memory_usage_stats); |
141 } | 142 } |
142 callback.Run(video_memory_usage_stats); | 143 callback.Run(video_memory_usage_stats); |
143 } | 144 } |
144 | 145 |
| 146 void GpuService::RequestCompleteGpuInfo( |
| 147 const RequestCompleteGpuInfoCallback& callback) { |
| 148 UpdateGpuInfoPlatform(); |
| 149 callback.Run(gpu_info_); |
| 150 } |
| 151 |
| 152 #if defined(OS_MACOSX) |
| 153 void GpuService::UpdateGpuInfoPlatform() { |
| 154 // gpu::CollectContextGraphicsInfo() is already called during gpu process |
| 155 // initialization (see GpuInit::InitializeAndStartSandbox()) on non-mac |
| 156 // platforms, and during in-browser gpu thread initialization on all platforms |
| 157 // (See InProcessGpuThread::Init()). |
| 158 if (in_host_process_) |
| 159 return; |
| 160 |
| 161 DCHECK_EQ(gpu::kCollectInfoNone, gpu_info_.context_info_state); |
| 162 gpu::CollectInfoResult result = gpu::CollectContextGraphicsInfo(&gpu_info_); |
| 163 switch (result) { |
| 164 case gpu::kCollectInfoFatalFailure: |
| 165 LOG(ERROR) << "gpu::CollectGraphicsInfo failed (fatal)."; |
| 166 // TODO(piman): can we signal overall failure? |
| 167 break; |
| 168 case gpu::kCollectInfoNonFatalFailure: |
| 169 DVLOG(1) << "gpu::CollectGraphicsInfo failed (non-fatal)."; |
| 170 break; |
| 171 case gpu::kCollectInfoNone: |
| 172 NOTREACHED(); |
| 173 break; |
| 174 case gpu::kCollectInfoSuccess: |
| 175 break; |
| 176 } |
| 177 } |
| 178 #elif defined(OS_WIN) |
| 179 void GpuService::UpdateGpuInfoPlatform() { |
| 180 // GPU full info collection should only happen on un-sandboxed GPU process |
| 181 // or single process/in-process gpu mode on Windows. |
| 182 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 183 DCHECK(command_line->HasSwitch("disable-gpu-sandbox") || in_host_process_); |
| 184 |
| 185 // This is slow, but it's the only thing the unsandboxed GPU process does, |
| 186 // and GpuDataManager prevents us from sending multiple collecting requests, |
| 187 // so it's OK to be blocking. |
| 188 gpu::GetDxDiagnostics(&gpu_info_.dx_diagnostics); |
| 189 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoSuccess; |
| 190 if (!in_host_process_) { |
| 191 // The unsandboxed GPU process fulfilled its duty. Rest in peace. |
| 192 base::MessageLoop::current()->QuitWhenIdle(); |
| 193 } |
| 194 } |
| 195 #else |
| 196 void GpuService::UpdateGpuInfoPlatform() {} |
| 197 #endif |
| 198 |
145 void GpuService::DidCreateOffscreenContext(const GURL& active_url) { | 199 void GpuService::DidCreateOffscreenContext(const GURL& active_url) { |
146 gpu_host_->DidCreateOffscreenContext(active_url); | 200 gpu_host_->DidCreateOffscreenContext(active_url); |
147 } | 201 } |
148 | 202 |
149 void GpuService::DidDestroyChannel(int client_id) { | 203 void GpuService::DidDestroyChannel(int client_id) { |
150 media_gpu_channel_manager_->RemoveChannel(client_id); | 204 media_gpu_channel_manager_->RemoveChannel(client_id); |
151 gpu_host_->DidDestroyChannel(client_id); | 205 gpu_host_->DidDestroyChannel(client_id); |
152 } | 206 } |
153 | 207 |
154 void GpuService::DidDestroyOffscreenContext(const GURL& active_url) { | 208 void GpuService::DidDestroyOffscreenContext(const GURL& active_url) { |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 NOTREACHED() << "Java exception not supported on this platform."; | 320 NOTREACHED() << "Java exception not supported on this platform."; |
267 #endif | 321 #endif |
268 } | 322 } |
269 | 323 |
270 void GpuService::Stop(const StopCallback& callback) { | 324 void GpuService::Stop(const StopCallback& callback) { |
271 base::MessageLoop::current()->QuitWhenIdle(); | 325 base::MessageLoop::current()->QuitWhenIdle(); |
272 callback.Run(); | 326 callback.Run(); |
273 } | 327 } |
274 | 328 |
275 } // namespace ui | 329 } // namespace ui |
OLD | NEW |