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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 }; | 325 }; |
326 | 326 |
327 } // namespace anonymous | 327 } // namespace anonymous |
328 | 328 |
329 void GpuDataManagerImplPrivate::InitializeForTesting( | 329 void GpuDataManagerImplPrivate::InitializeForTesting( |
330 const std::string& gpu_blacklist_json, | 330 const std::string& gpu_blacklist_json, |
331 const gpu::GPUInfo& gpu_info) { | 331 const gpu::GPUInfo& gpu_info) { |
332 // This function is for testing only, so disable histograms. | 332 // This function is for testing only, so disable histograms. |
333 update_histograms_ = false; | 333 update_histograms_ = false; |
334 | 334 |
| 335 // Prevent all further initialization. |
| 336 finalized_ = true; |
| 337 |
335 InitializeImpl(gpu_blacklist_json, std::string(), std::string(), gpu_info); | 338 InitializeImpl(gpu_blacklist_json, std::string(), std::string(), gpu_info); |
336 } | 339 } |
337 | 340 |
338 bool GpuDataManagerImplPrivate::IsFeatureBlacklisted(int feature) const { | 341 bool GpuDataManagerImplPrivate::IsFeatureBlacklisted(int feature) const { |
339 #if defined(OS_CHROMEOS) | 342 #if defined(OS_CHROMEOS) |
340 if (feature == gpu::GPU_FEATURE_TYPE_PANEL_FITTING && | 343 if (feature == gpu::GPU_FEATURE_TYPE_PANEL_FITTING && |
341 CommandLine::ForCurrentProcess()->HasSwitch( | 344 CommandLine::ForCurrentProcess()->HasSwitch( |
342 switches::kDisablePanelFitting)) { | 345 switches::kDisablePanelFitting)) { |
343 return true; | 346 return true; |
344 } | 347 } |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 std::string* gl_version) { | 541 std::string* gl_version) { |
539 DCHECK(gl_vendor && gl_renderer && gl_version); | 542 DCHECK(gl_vendor && gl_renderer && gl_version); |
540 | 543 |
541 *gl_vendor = gpu_info_.gl_vendor; | 544 *gl_vendor = gpu_info_.gl_vendor; |
542 *gl_renderer = gpu_info_.gl_renderer; | 545 *gl_renderer = gpu_info_.gl_renderer; |
543 *gl_version = gpu_info_.gl_version_string; | 546 *gl_version = gpu_info_.gl_version_string; |
544 } | 547 } |
545 | 548 |
546 void GpuDataManagerImplPrivate::Initialize() { | 549 void GpuDataManagerImplPrivate::Initialize() { |
547 TRACE_EVENT0("startup", "GpuDataManagerImpl::Initialize"); | 550 TRACE_EVENT0("startup", "GpuDataManagerImpl::Initialize"); |
548 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 551 if (finalized_) { |
549 if (command_line->HasSwitch(switches::kSkipGpuDataLoading) && | 552 DLOG(INFO) << "GpuDataManagerImpl marked as finalized; skipping Initialize"; |
550 !command_line->HasSwitch(switches::kUseGpuInTests)) | 553 return; |
| 554 } |
| 555 |
| 556 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 557 if (command_line->HasSwitch(switches::kSkipGpuDataLoading)) |
551 return; | 558 return; |
552 | 559 |
553 gpu::GPUInfo gpu_info; | 560 gpu::GPUInfo gpu_info; |
554 { | 561 if (command_line->GetSwitchValueASCII( |
| 562 switches::kUseGL) == gfx::kGLImplementationOSMesaName) { |
| 563 // If using the OSMesa GL implementation, use fake vendor and device ids to |
| 564 // make sure it never gets blacklisted. This is better than simply |
| 565 // cancelling GPUInfo gathering as it allows us to proceed with loading the |
| 566 // blacklist below which may have non-device specific entries we want to |
| 567 // apply anyways (e.g., OS version blacklisting). |
| 568 gpu_info.gpu.vendor_id = 0xffff; |
| 569 gpu_info.gpu.device_id = 0xffff; |
| 570 |
| 571 // Hardcode some values otherwise some blacklisting rules in |
| 572 // kSoftwareRenderingListJson result in a positive match as GpuControlList |
| 573 // assumes a match (by design) when a property is required for the |
| 574 // verification yet not present in the GpuInfo. |
| 575 gpu_info.driver_vendor = |
| 576 gfx::kGLImplementationOSMesaName; // Bypass rule #74. |
| 577 gpu_info.driver_date = "2013.8"; // Bypass rules #12 and #55. |
| 578 gpu_info.driver_version = "9.0.3"; // Bypass rule #23. |
| 579 } else { |
555 TRACE_EVENT0("startup", | 580 TRACE_EVENT0("startup", |
556 "GpuDataManagerImpl::Initialize:CollectBasicGraphicsInfo"); | 581 "GpuDataManagerImpl::Initialize:CollectBasicGraphicsInfo"); |
557 gpu::CollectBasicGraphicsInfo(&gpu_info); | 582 gpu::CollectBasicGraphicsInfo(&gpu_info); |
558 } | 583 } |
559 #if defined(ARCH_CPU_X86_FAMILY) | 584 #if defined(ARCH_CPU_X86_FAMILY) |
560 if (!gpu_info.gpu.vendor_id || !gpu_info.gpu.device_id) | 585 if (!gpu_info.gpu.vendor_id || !gpu_info.gpu.device_id) |
561 gpu_info.finalized = true; | 586 gpu_info.finalized = true; |
562 #endif | 587 #endif |
563 | 588 |
564 std::string gpu_blacklist_string; | 589 std::string gpu_blacklist_string; |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
978 gpu_switching_(gpu::GPU_SWITCHING_OPTION_AUTOMATIC), | 1003 gpu_switching_(gpu::GPU_SWITCHING_OPTION_AUTOMATIC), |
979 observer_list_(new GpuDataManagerObserverList), | 1004 observer_list_(new GpuDataManagerObserverList), |
980 use_swiftshader_(false), | 1005 use_swiftshader_(false), |
981 card_blacklisted_(false), | 1006 card_blacklisted_(false), |
982 update_histograms_(true), | 1007 update_histograms_(true), |
983 window_count_(0), | 1008 window_count_(0), |
984 domain_blocking_enabled_(true), | 1009 domain_blocking_enabled_(true), |
985 owner_(owner), | 1010 owner_(owner), |
986 display_count_(0), | 1011 display_count_(0), |
987 gpu_process_accessible_(true), | 1012 gpu_process_accessible_(true), |
988 use_software_compositor_(false) { | 1013 use_software_compositor_(false), |
| 1014 finalized_(false) { |
989 DCHECK(owner_); | 1015 DCHECK(owner_); |
990 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 1016 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
991 if (command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) { | 1017 if (command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) { |
992 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas); | 1018 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas); |
993 command_line->AppendSwitch(switches::kDisableAcceleratedLayers); | 1019 command_line->AppendSwitch(switches::kDisableAcceleratedLayers); |
994 } | 1020 } |
995 if (command_line->HasSwitch(switches::kDisableGpu)) | 1021 if (command_line->HasSwitch(switches::kDisableGpu)) |
996 DisableHardwareAcceleration(); | 1022 DisableHardwareAcceleration(); |
997 if (command_line->HasSwitch(switches::kEnableSoftwareCompositing)) | 1023 if (command_line->HasSwitch(switches::kEnableSoftwareCompositing)) |
998 use_software_compositor_ = true; | 1024 use_software_compositor_ = true; |
(...skipping 26 matching lines...) Expand all Loading... |
1025 const std::string& gpu_blacklist_json, | 1051 const std::string& gpu_blacklist_json, |
1026 const std::string& gpu_switching_list_json, | 1052 const std::string& gpu_switching_list_json, |
1027 const std::string& gpu_driver_bug_list_json, | 1053 const std::string& gpu_driver_bug_list_json, |
1028 const gpu::GPUInfo& gpu_info) { | 1054 const gpu::GPUInfo& gpu_info) { |
1029 std::string browser_version_string = ProcessVersionString( | 1055 std::string browser_version_string = ProcessVersionString( |
1030 GetContentClient()->GetProduct()); | 1056 GetContentClient()->GetProduct()); |
1031 CHECK(!browser_version_string.empty()); | 1057 CHECK(!browser_version_string.empty()); |
1032 | 1058 |
1033 if (!gpu_blacklist_json.empty()) { | 1059 if (!gpu_blacklist_json.empty()) { |
1034 gpu_blacklist_.reset(gpu::GpuBlacklist::Create()); | 1060 gpu_blacklist_.reset(gpu::GpuBlacklist::Create()); |
| 1061 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 1062 switches::kLogGpuControlListDecisions)) { |
| 1063 gpu_blacklist_->enable_control_list_logging(); |
| 1064 } |
1035 gpu_blacklist_->LoadList( | 1065 gpu_blacklist_->LoadList( |
1036 browser_version_string, gpu_blacklist_json, | 1066 browser_version_string, gpu_blacklist_json, |
1037 gpu::GpuControlList::kCurrentOsOnly); | 1067 gpu::GpuControlList::kCurrentOsOnly); |
1038 } | 1068 } |
1039 if (!gpu_switching_list_json.empty()) { | 1069 if (!gpu_switching_list_json.empty()) { |
1040 gpu_switching_list_.reset(gpu::GpuSwitchingList::Create()); | 1070 gpu_switching_list_.reset(gpu::GpuSwitchingList::Create()); |
1041 gpu_switching_list_->LoadList( | 1071 gpu_switching_list_->LoadList( |
1042 browser_version_string, gpu_switching_list_json, | 1072 browser_version_string, gpu_switching_list_json, |
1043 gpu::GpuControlList::kCurrentOsOnly); | 1073 gpu::GpuControlList::kCurrentOsOnly); |
1044 } | 1074 } |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1235 | 1265 |
1236 void GpuDataManagerImplPrivate::OnGpuProcessInitFailure() { | 1266 void GpuDataManagerImplPrivate::OnGpuProcessInitFailure() { |
1237 gpu_process_accessible_ = false; | 1267 gpu_process_accessible_ = false; |
1238 gpu_info_.finalized = true; | 1268 gpu_info_.finalized = true; |
1239 complete_gpu_info_already_requested_ = true; | 1269 complete_gpu_info_already_requested_ = true; |
1240 // Some observers might be waiting. | 1270 // Some observers might be waiting. |
1241 NotifyGpuInfoUpdate(); | 1271 NotifyGpuInfoUpdate(); |
1242 } | 1272 } |
1243 | 1273 |
1244 } // namespace content | 1274 } // namespace content |
OLD | NEW |