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 345 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(true)) |
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::IsCompleteGpuInfoAvailable() const { | 380 bool GpuDataManagerImplPrivate::IsCompleteGpuInfoAvailable( |
381 return gpu_info_.finalized; | 381 bool includes_extra) const { |
382 if (gpu_info_.basic_info_state == gpu::kCollectInfoNone || | |
383 gpu_info_.context_info_state == gpu::kCollectInfoNone) | |
384 return false; | |
385 #if defined(OS_WIN) | |
386 if (gpu_info_.dx_diagnostics_info_state == gpu::kCollectInfoNone) | |
piman
2014/09/03 00:50:55
did you mean && includes_extra here?
Otherwise, i
Zhenyao Mo
2014/09/03 01:31:23
Per estatde's comment, I divide into two functions
| |
387 return false; | |
388 #endif | |
389 return true; | |
382 } | 390 } |
383 | 391 |
384 void GpuDataManagerImplPrivate::RequestVideoMemoryUsageStatsUpdate() const { | 392 void GpuDataManagerImplPrivate::RequestVideoMemoryUsageStatsUpdate() const { |
385 GpuProcessHost::SendOnIO( | 393 GpuProcessHost::SendOnIO( |
386 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, | 394 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, |
387 CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, | 395 CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, |
388 new GpuMsg_GetVideoMemoryUsageStats()); | 396 new GpuMsg_GetVideoMemoryUsageStats()); |
389 } | 397 } |
390 | 398 |
391 bool GpuDataManagerImplPrivate::ShouldUseSwiftShader() const { | 399 bool GpuDataManagerImplPrivate::ShouldUseSwiftShader() const { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
496 | 504 |
497 // Also declare the driver_vendor to be osmesa to be able to specify | 505 // Also declare the driver_vendor to be osmesa to be able to specify |
498 // exceptions based on driver_vendor==osmesa for some blacklist rules. | 506 // exceptions based on driver_vendor==osmesa for some blacklist rules. |
499 gpu_info.driver_vendor = gfx::kGLImplementationOSMesaName; | 507 gpu_info.driver_vendor = gfx::kGLImplementationOSMesaName; |
500 } else { | 508 } else { |
501 TRACE_EVENT0("startup", | 509 TRACE_EVENT0("startup", |
502 "GpuDataManagerImpl::Initialize:CollectBasicGraphicsInfo"); | 510 "GpuDataManagerImpl::Initialize:CollectBasicGraphicsInfo"); |
503 gpu::CollectBasicGraphicsInfo(&gpu_info); | 511 gpu::CollectBasicGraphicsInfo(&gpu_info); |
504 } | 512 } |
505 #if defined(ARCH_CPU_X86_FAMILY) | 513 #if defined(ARCH_CPU_X86_FAMILY) |
506 if (!gpu_info.gpu.vendor_id || !gpu_info.gpu.device_id) | 514 if (!gpu_info.gpu.vendor_id || !gpu_info.gpu.device_id) { |
507 gpu_info.finalized = true; | 515 gpu_info.context_info_state = gpu::kCollectInfoNonFatalFailure; |
508 #endif | 516 #if defined(OS_WIN) |
517 gpu_info.dx_diagnostics_info_state = gpu::kCollectInfoNonFatalFailure; | |
518 #endif // OS_WIN | |
519 } | |
520 #endif // ARCH_CPU_X86_FAMILY | |
509 | 521 |
510 std::string gpu_blacklist_string; | 522 std::string gpu_blacklist_string; |
511 std::string gpu_driver_bug_list_string; | 523 std::string gpu_driver_bug_list_string; |
512 if (!command_line->HasSwitch(switches::kIgnoreGpuBlacklist) && | 524 if (!command_line->HasSwitch(switches::kIgnoreGpuBlacklist) && |
513 !command_line->HasSwitch(switches::kUseGpuInTests)) { | 525 !command_line->HasSwitch(switches::kUseGpuInTests)) { |
514 gpu_blacklist_string = gpu::kSoftwareRenderingListJson; | 526 gpu_blacklist_string = gpu::kSoftwareRenderingListJson; |
515 } | 527 } |
516 if (!command_line->HasSwitch(switches::kDisableGpuDriverBugWorkarounds)) { | 528 if (!command_line->HasSwitch(switches::kDisableGpuDriverBugWorkarounds)) { |
517 gpu_driver_bug_list_string = gpu::kGpuDriverBugListJson; | 529 gpu_driver_bug_list_string = gpu::kGpuDriverBugListJson; |
518 } | 530 } |
(...skipping 23 matching lines...) Expand all Loading... | |
542 // We have to update GpuFeatureType before notify all the observers. | 554 // We have to update GpuFeatureType before notify all the observers. |
543 NotifyGpuInfoUpdate(); | 555 NotifyGpuInfoUpdate(); |
544 } | 556 } |
545 | 557 |
546 void GpuDataManagerImplPrivate::UpdateGpuInfo(const gpu::GPUInfo& gpu_info) { | 558 void GpuDataManagerImplPrivate::UpdateGpuInfo(const gpu::GPUInfo& gpu_info) { |
547 // No further update of gpu_info if falling back to SwiftShader. | 559 // No further update of gpu_info if falling back to SwiftShader. |
548 if (use_swiftshader_) | 560 if (use_swiftshader_) |
549 return; | 561 return; |
550 | 562 |
551 gpu::MergeGPUInfo(&gpu_info_, gpu_info); | 563 gpu::MergeGPUInfo(&gpu_info_, gpu_info); |
552 complete_gpu_info_already_requested_ = | 564 if (IsCompleteGpuInfoAvailable(true)) |
553 complete_gpu_info_already_requested_ || gpu_info_.finalized; | 565 complete_gpu_info_already_requested_ = true; |
554 | 566 |
555 UpdateGpuInfoHelper(); | 567 UpdateGpuInfoHelper(); |
556 } | 568 } |
557 | 569 |
558 void GpuDataManagerImplPrivate::UpdateVideoMemoryUsageStats( | 570 void GpuDataManagerImplPrivate::UpdateVideoMemoryUsageStats( |
559 const GPUVideoMemoryUsageStats& video_memory_usage_stats) { | 571 const GPUVideoMemoryUsageStats& video_memory_usage_stats) { |
560 GpuDataManagerImpl::UnlockedSession session(owner_); | 572 GpuDataManagerImpl::UnlockedSession session(owner_); |
561 observer_list_->Notify(&GpuDataManagerObserver::OnVideoMemoryUsageStatsUpdate, | 573 observer_list_->Notify(&GpuDataManagerObserver::OnVideoMemoryUsageStatsUpdate, |
562 video_memory_usage_stats); | 574 video_memory_usage_stats); |
563 } | 575 } |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1066 int render_process_id, | 1078 int render_process_id, |
1067 int render_view_id, | 1079 int render_view_id, |
1068 ThreeDAPIType requester) { | 1080 ThreeDAPIType requester) { |
1069 GpuDataManagerImpl::UnlockedSession session(owner_); | 1081 GpuDataManagerImpl::UnlockedSession session(owner_); |
1070 observer_list_->Notify(&GpuDataManagerObserver::DidBlock3DAPIs, | 1082 observer_list_->Notify(&GpuDataManagerObserver::DidBlock3DAPIs, |
1071 url, render_process_id, render_view_id, requester); | 1083 url, render_process_id, render_view_id, requester); |
1072 } | 1084 } |
1073 | 1085 |
1074 void GpuDataManagerImplPrivate::OnGpuProcessInitFailure() { | 1086 void GpuDataManagerImplPrivate::OnGpuProcessInitFailure() { |
1075 gpu_process_accessible_ = false; | 1087 gpu_process_accessible_ = false; |
1076 gpu_info_.finalized = true; | 1088 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure; |
1089 #if defined(OS_WIN) | |
1090 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure; | |
1091 #endif | |
1077 complete_gpu_info_already_requested_ = true; | 1092 complete_gpu_info_already_requested_ = true; |
1078 // Some observers might be waiting. | 1093 // Some observers might be waiting. |
1079 NotifyGpuInfoUpdate(); | 1094 NotifyGpuInfoUpdate(); |
1080 } | 1095 } |
1081 | 1096 |
1082 } // namespace content | 1097 } // namespace content |
OLD | NEW |