OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "content/browser/gpu/gpu_data_manager_impl_private.h" | 5 #include "content/browser/gpu/gpu_data_manager_impl_private.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
219 CGGetActiveDisplayList(0, NULL, &displayCount); | 219 CGGetActiveDisplayList(0, NULL, &displayCount); |
220 if (displayCount != manager->GetDisplayCount()) { | 220 if (displayCount != manager->GetDisplayCount()) { |
221 manager->SetDisplayCount(displayCount); | 221 manager->SetDisplayCount(displayCount); |
222 display_changed = true; | 222 display_changed = true; |
223 } | 223 } |
224 | 224 |
225 // Gpu change. | 225 // Gpu change. |
226 bool gpu_changed = false; | 226 bool gpu_changed = false; |
227 if (flags & kCGDisplayAddFlag) { | 227 if (flags & kCGDisplayAddFlag) { |
228 uint32 vendor_id, device_id; | 228 uint32 vendor_id, device_id; |
229 if (gpu::CollectGpuID(&vendor_id, &device_id) == gpu::kGpuIDSuccess) { | 229 if (gpu::CollectGpuID(&vendor_id, &device_id) == gpu::kCollectInfoSuccess) { |
230 gpu_changed = manager->UpdateActiveGpu(vendor_id, device_id); | 230 gpu_changed = manager->UpdateActiveGpu(vendor_id, device_id); |
231 } | 231 } |
232 } | 232 } |
233 | 233 |
234 if (display_changed || gpu_changed) | 234 if (display_changed || gpu_changed) |
235 manager->HandleGpuSwitch(); | 235 manager->HandleGpuSwitch(); |
236 } | 236 } |
237 #endif // OS_MACOSX | 237 #endif // OS_MACOSX |
238 | 238 |
239 // Block all domains' use of 3D APIs for this many milliseconds if | 239 // Block all domains' use of 3D APIs for this many milliseconds if |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
356 *reason = "All GPU features are blacklisted."; | 356 *reason = "All GPU features are blacklisted."; |
357 } | 357 } |
358 return false; | 358 return false; |
359 #endif | 359 #endif |
360 } | 360 } |
361 | 361 |
362 return true; | 362 return true; |
363 } | 363 } |
364 | 364 |
365 void GpuDataManagerImplPrivate::RequestCompleteGpuInfoIfNeeded() { | 365 void GpuDataManagerImplPrivate::RequestCompleteGpuInfoIfNeeded() { |
366 if (complete_gpu_info_already_requested_ || gpu_info_.finalized) | 366 if (complete_gpu_info_already_requested_ || IsCompleteGpuInfoAvailable()) |
367 return; | 367 return; |
368 complete_gpu_info_already_requested_ = true; | 368 complete_gpu_info_already_requested_ = true; |
369 | 369 |
370 GpuProcessHost::SendOnIO( | 370 GpuProcessHost::SendOnIO( |
371 #if defined(OS_WIN) | 371 #if defined(OS_WIN) |
372 GpuProcessHost::GPU_PROCESS_KIND_UNSANDBOXED, | 372 GpuProcessHost::GPU_PROCESS_KIND_UNSANDBOXED, |
373 #else | 373 #else |
374 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, | 374 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, |
375 #endif | 375 #endif |
376 CAUSE_FOR_GPU_LAUNCH_GPUDATAMANAGER_REQUESTCOMPLETEGPUINFOIFNEEDED, | 376 CAUSE_FOR_GPU_LAUNCH_GPUDATAMANAGER_REQUESTCOMPLETEGPUINFOIFNEEDED, |
377 new GpuMsg_CollectGraphicsInfo()); | 377 new GpuMsg_CollectGraphicsInfo()); |
378 } | 378 } |
379 | 379 |
380 bool GpuDataManagerImplPrivate::IsEssentialGpuInfoAvailable() const { | |
381 if (gpu_info_.basic_info_state == gpu::kCollectInfoNone || | |
382 gpu_info_.context_info_state == gpu::kCollectInfoNone) | |
Evan Stade
2014/09/03 21:47:58
nit: curlies
Zhenyao Mo
2014/09/03 21:56:10
Done.
| |
383 return false; | |
384 return true; | |
385 } | |
386 | |
380 bool GpuDataManagerImplPrivate::IsCompleteGpuInfoAvailable() const { | 387 bool GpuDataManagerImplPrivate::IsCompleteGpuInfoAvailable() const { |
Evan Stade
2014/09/03 21:47:58
{
#if defined(OS_WIN)
...
#endif
return IsEsse
Zhenyao Mo
2014/09/03 21:56:10
Done.
| |
381 return gpu_info_.finalized; | 388 if (!IsEssentialGpuInfoAvailable()) |
389 return false; | |
390 #if defined(OS_WIN) | |
391 if (gpu_info_.dx_diagnostics_info_state == gpu::kCollectInfoNone) | |
392 return false; | |
393 #endif | |
394 return true; | |
382 } | 395 } |
383 | 396 |
384 void GpuDataManagerImplPrivate::RequestVideoMemoryUsageStatsUpdate() const { | 397 void GpuDataManagerImplPrivate::RequestVideoMemoryUsageStatsUpdate() const { |
385 GpuProcessHost::SendOnIO( | 398 GpuProcessHost::SendOnIO( |
386 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, | 399 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, |
387 CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, | 400 CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, |
388 new GpuMsg_GetVideoMemoryUsageStats()); | 401 new GpuMsg_GetVideoMemoryUsageStats()); |
389 } | 402 } |
390 | 403 |
391 bool GpuDataManagerImplPrivate::ShouldUseSwiftShader() const { | 404 bool GpuDataManagerImplPrivate::ShouldUseSwiftShader() const { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
496 | 509 |
497 // Also declare the driver_vendor to be osmesa to be able to specify | 510 // Also declare the driver_vendor to be osmesa to be able to specify |
498 // exceptions based on driver_vendor==osmesa for some blacklist rules. | 511 // exceptions based on driver_vendor==osmesa for some blacklist rules. |
499 gpu_info.driver_vendor = gfx::kGLImplementationOSMesaName; | 512 gpu_info.driver_vendor = gfx::kGLImplementationOSMesaName; |
500 } else { | 513 } else { |
501 TRACE_EVENT0("startup", | 514 TRACE_EVENT0("startup", |
502 "GpuDataManagerImpl::Initialize:CollectBasicGraphicsInfo"); | 515 "GpuDataManagerImpl::Initialize:CollectBasicGraphicsInfo"); |
503 gpu::CollectBasicGraphicsInfo(&gpu_info); | 516 gpu::CollectBasicGraphicsInfo(&gpu_info); |
504 } | 517 } |
505 #if defined(ARCH_CPU_X86_FAMILY) | 518 #if defined(ARCH_CPU_X86_FAMILY) |
506 if (!gpu_info.gpu.vendor_id || !gpu_info.gpu.device_id) | 519 if (!gpu_info.gpu.vendor_id || !gpu_info.gpu.device_id) { |
507 gpu_info.finalized = true; | 520 gpu_info.context_info_state = gpu::kCollectInfoNonFatalFailure; |
508 #endif | 521 #if defined(OS_WIN) |
522 gpu_info.dx_diagnostics_info_state = gpu::kCollectInfoNonFatalFailure; | |
523 #endif // OS_WIN | |
524 } | |
525 #endif // ARCH_CPU_X86_FAMILY | |
509 | 526 |
510 std::string gpu_blacklist_string; | 527 std::string gpu_blacklist_string; |
511 std::string gpu_driver_bug_list_string; | 528 std::string gpu_driver_bug_list_string; |
512 if (!command_line->HasSwitch(switches::kIgnoreGpuBlacklist) && | 529 if (!command_line->HasSwitch(switches::kIgnoreGpuBlacklist) && |
513 !command_line->HasSwitch(switches::kUseGpuInTests)) { | 530 !command_line->HasSwitch(switches::kUseGpuInTests)) { |
514 gpu_blacklist_string = gpu::kSoftwareRenderingListJson; | 531 gpu_blacklist_string = gpu::kSoftwareRenderingListJson; |
515 } | 532 } |
516 if (!command_line->HasSwitch(switches::kDisableGpuDriverBugWorkarounds)) { | 533 if (!command_line->HasSwitch(switches::kDisableGpuDriverBugWorkarounds)) { |
517 gpu_driver_bug_list_string = gpu::kGpuDriverBugListJson; | 534 gpu_driver_bug_list_string = gpu::kGpuDriverBugListJson; |
518 } | 535 } |
(...skipping 23 matching lines...) Expand all Loading... | |
542 // We have to update GpuFeatureType before notify all the observers. | 559 // We have to update GpuFeatureType before notify all the observers. |
543 NotifyGpuInfoUpdate(); | 560 NotifyGpuInfoUpdate(); |
544 } | 561 } |
545 | 562 |
546 void GpuDataManagerImplPrivate::UpdateGpuInfo(const gpu::GPUInfo& gpu_info) { | 563 void GpuDataManagerImplPrivate::UpdateGpuInfo(const gpu::GPUInfo& gpu_info) { |
547 // No further update of gpu_info if falling back to SwiftShader. | 564 // No further update of gpu_info if falling back to SwiftShader. |
548 if (use_swiftshader_) | 565 if (use_swiftshader_) |
549 return; | 566 return; |
550 | 567 |
551 gpu::MergeGPUInfo(&gpu_info_, gpu_info); | 568 gpu::MergeGPUInfo(&gpu_info_, gpu_info); |
552 complete_gpu_info_already_requested_ = | 569 if (IsCompleteGpuInfoAvailable()) |
553 complete_gpu_info_already_requested_ || gpu_info_.finalized; | 570 complete_gpu_info_already_requested_ = true; |
554 | 571 |
555 UpdateGpuInfoHelper(); | 572 UpdateGpuInfoHelper(); |
556 } | 573 } |
557 | 574 |
558 void GpuDataManagerImplPrivate::UpdateVideoMemoryUsageStats( | 575 void GpuDataManagerImplPrivate::UpdateVideoMemoryUsageStats( |
559 const GPUVideoMemoryUsageStats& video_memory_usage_stats) { | 576 const GPUVideoMemoryUsageStats& video_memory_usage_stats) { |
560 GpuDataManagerImpl::UnlockedSession session(owner_); | 577 GpuDataManagerImpl::UnlockedSession session(owner_); |
561 observer_list_->Notify(&GpuDataManagerObserver::OnVideoMemoryUsageStatsUpdate, | 578 observer_list_->Notify(&GpuDataManagerObserver::OnVideoMemoryUsageStatsUpdate, |
562 video_memory_usage_stats); | 579 video_memory_usage_stats); |
563 } | 580 } |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1066 int render_process_id, | 1083 int render_process_id, |
1067 int render_view_id, | 1084 int render_view_id, |
1068 ThreeDAPIType requester) { | 1085 ThreeDAPIType requester) { |
1069 GpuDataManagerImpl::UnlockedSession session(owner_); | 1086 GpuDataManagerImpl::UnlockedSession session(owner_); |
1070 observer_list_->Notify(&GpuDataManagerObserver::DidBlock3DAPIs, | 1087 observer_list_->Notify(&GpuDataManagerObserver::DidBlock3DAPIs, |
1071 url, render_process_id, render_view_id, requester); | 1088 url, render_process_id, render_view_id, requester); |
1072 } | 1089 } |
1073 | 1090 |
1074 void GpuDataManagerImplPrivate::OnGpuProcessInitFailure() { | 1091 void GpuDataManagerImplPrivate::OnGpuProcessInitFailure() { |
1075 gpu_process_accessible_ = false; | 1092 gpu_process_accessible_ = false; |
1076 gpu_info_.finalized = true; | 1093 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure; |
1094 #if defined(OS_WIN) | |
1095 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure; | |
1096 #endif | |
1077 complete_gpu_info_already_requested_ = true; | 1097 complete_gpu_info_already_requested_ = true; |
1078 // Some observers might be waiting. | 1098 // Some observers might be waiting. |
1079 NotifyGpuInfoUpdate(); | 1099 NotifyGpuInfoUpdate(); |
1080 } | 1100 } |
1081 | 1101 |
1082 } // namespace content | 1102 } // namespace content |
OLD | NEW |