| 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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 }; | 313 }; |
| 314 | 314 |
| 315 } // namespace anonymous | 315 } // namespace anonymous |
| 316 | 316 |
| 317 void GpuDataManagerImplPrivate::InitializeForTesting( | 317 void GpuDataManagerImplPrivate::InitializeForTesting( |
| 318 const std::string& gpu_blacklist_json, | 318 const std::string& gpu_blacklist_json, |
| 319 const gpu::GPUInfo& gpu_info) { | 319 const gpu::GPUInfo& gpu_info) { |
| 320 // This function is for testing only, so disable histograms. | 320 // This function is for testing only, so disable histograms. |
| 321 update_histograms_ = false; | 321 update_histograms_ = false; |
| 322 | 322 |
| 323 // Prevent all further initialization. | |
| 324 finalized_ = true; | |
| 325 | |
| 326 InitializeImpl(gpu_blacklist_json, std::string(), std::string(), gpu_info); | 323 InitializeImpl(gpu_blacklist_json, std::string(), std::string(), gpu_info); |
| 327 } | 324 } |
| 328 | 325 |
| 329 bool GpuDataManagerImplPrivate::IsFeatureBlacklisted(int feature) const { | 326 bool GpuDataManagerImplPrivate::IsFeatureBlacklisted(int feature) const { |
| 330 #if defined(OS_CHROMEOS) | 327 #if defined(OS_CHROMEOS) |
| 331 if (feature == gpu::GPU_FEATURE_TYPE_PANEL_FITTING && | 328 if (feature == gpu::GPU_FEATURE_TYPE_PANEL_FITTING && |
| 332 CommandLine::ForCurrentProcess()->HasSwitch( | 329 CommandLine::ForCurrentProcess()->HasSwitch( |
| 333 switches::kDisablePanelFitting)) { | 330 switches::kDisablePanelFitting)) { |
| 334 return true; | 331 return true; |
| 335 } | 332 } |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 std::string* gl_version) { | 526 std::string* gl_version) { |
| 530 DCHECK(gl_vendor && gl_renderer && gl_version); | 527 DCHECK(gl_vendor && gl_renderer && gl_version); |
| 531 | 528 |
| 532 *gl_vendor = gpu_info_.gl_vendor; | 529 *gl_vendor = gpu_info_.gl_vendor; |
| 533 *gl_renderer = gpu_info_.gl_renderer; | 530 *gl_renderer = gpu_info_.gl_renderer; |
| 534 *gl_version = gpu_info_.gl_version_string; | 531 *gl_version = gpu_info_.gl_version_string; |
| 535 } | 532 } |
| 536 | 533 |
| 537 void GpuDataManagerImplPrivate::Initialize() { | 534 void GpuDataManagerImplPrivate::Initialize() { |
| 538 TRACE_EVENT0("startup", "GpuDataManagerImpl::Initialize"); | 535 TRACE_EVENT0("startup", "GpuDataManagerImpl::Initialize"); |
| 539 if (finalized_) { | 536 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 540 DLOG(INFO) << "GpuDataManagerImpl marked as finalized; skipping Initialize"; | 537 if (command_line->HasSwitch(switches::kSkipGpuDataLoading) && |
| 541 return; | 538 !command_line->HasSwitch(switches::kUseGpuInTests)) |
| 542 } | |
| 543 | |
| 544 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
| 545 if (command_line->HasSwitch(switches::kSkipGpuDataLoading)) | |
| 546 return; | 539 return; |
| 547 | 540 |
| 548 gpu::GPUInfo gpu_info; | 541 gpu::GPUInfo gpu_info; |
| 549 if (command_line->GetSwitchValueASCII( | 542 { |
| 550 switches::kUseGL) == gfx::kGLImplementationOSMesaName) { | |
| 551 // If using the OSMesa GL implementation, use fake vendor and device ids to | |
| 552 // make sure it never gets blacklisted. This is better than simply | |
| 553 // cancelling GPUInfo gathering as it allows us to proceed with loading the | |
| 554 // blacklist below which may have non-device specific entries we want to | |
| 555 // apply anyways (e.g., OS version blacklisting). | |
| 556 gpu_info.gpu.vendor_id = 0xffff; | |
| 557 gpu_info.gpu.device_id = 0xffff; | |
| 558 | |
| 559 // Also declare the driver_vendor to be osmesa to be able to specify | |
| 560 // exceptions based on driver_vendor==osmesa for some blacklist rules. | |
| 561 gpu_info.driver_vendor = gfx::kGLImplementationOSMesaName; | |
| 562 } else { | |
| 563 TRACE_EVENT0("startup", | 543 TRACE_EVENT0("startup", |
| 564 "GpuDataManagerImpl::Initialize:CollectBasicGraphicsInfo"); | 544 "GpuDataManagerImpl::Initialize:CollectBasicGraphicsInfo"); |
| 565 gpu::CollectBasicGraphicsInfo(&gpu_info); | 545 gpu::CollectBasicGraphicsInfo(&gpu_info); |
| 566 } | 546 } |
| 567 #if defined(ARCH_CPU_X86_FAMILY) | 547 #if defined(ARCH_CPU_X86_FAMILY) |
| 568 if (!gpu_info.gpu.vendor_id || !gpu_info.gpu.device_id) | 548 if (!gpu_info.gpu.vendor_id || !gpu_info.gpu.device_id) |
| 569 gpu_info.finalized = true; | 549 gpu_info.finalized = true; |
| 570 #endif | 550 #endif |
| 571 | 551 |
| 572 std::string gpu_blacklist_string; | 552 std::string gpu_blacklist_string; |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 986 gpu_switching_(gpu::GPU_SWITCHING_OPTION_AUTOMATIC), | 966 gpu_switching_(gpu::GPU_SWITCHING_OPTION_AUTOMATIC), |
| 987 observer_list_(new GpuDataManagerObserverList), | 967 observer_list_(new GpuDataManagerObserverList), |
| 988 use_swiftshader_(false), | 968 use_swiftshader_(false), |
| 989 card_blacklisted_(false), | 969 card_blacklisted_(false), |
| 990 update_histograms_(true), | 970 update_histograms_(true), |
| 991 window_count_(0), | 971 window_count_(0), |
| 992 domain_blocking_enabled_(true), | 972 domain_blocking_enabled_(true), |
| 993 owner_(owner), | 973 owner_(owner), |
| 994 display_count_(0), | 974 display_count_(0), |
| 995 gpu_process_accessible_(true), | 975 gpu_process_accessible_(true), |
| 996 use_software_compositor_(false), | 976 use_software_compositor_(false) { |
| 997 finalized_(false) { | |
| 998 DCHECK(owner_); | 977 DCHECK(owner_); |
| 999 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 978 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 1000 if (command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) { | 979 if (command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) { |
| 1001 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas); | 980 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas); |
| 1002 command_line->AppendSwitch(switches::kDisableAcceleratedLayers); | 981 command_line->AppendSwitch(switches::kDisableAcceleratedLayers); |
| 1003 } | 982 } |
| 1004 if (command_line->HasSwitch(switches::kDisableGpu)) | 983 if (command_line->HasSwitch(switches::kDisableGpu)) |
| 1005 DisableHardwareAcceleration(); | 984 DisableHardwareAcceleration(); |
| 1006 if (command_line->HasSwitch(switches::kEnableSoftwareCompositing)) | 985 if (command_line->HasSwitch(switches::kEnableSoftwareCompositing)) |
| 1007 use_software_compositor_ = true; | 986 use_software_compositor_ = true; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1032 | 1011 |
| 1033 void GpuDataManagerImplPrivate::InitializeImpl( | 1012 void GpuDataManagerImplPrivate::InitializeImpl( |
| 1034 const std::string& gpu_blacklist_json, | 1013 const std::string& gpu_blacklist_json, |
| 1035 const std::string& gpu_switching_list_json, | 1014 const std::string& gpu_switching_list_json, |
| 1036 const std::string& gpu_driver_bug_list_json, | 1015 const std::string& gpu_driver_bug_list_json, |
| 1037 const gpu::GPUInfo& gpu_info) { | 1016 const gpu::GPUInfo& gpu_info) { |
| 1038 std::string browser_version_string = ProcessVersionString( | 1017 std::string browser_version_string = ProcessVersionString( |
| 1039 GetContentClient()->GetProduct()); | 1018 GetContentClient()->GetProduct()); |
| 1040 CHECK(!browser_version_string.empty()); | 1019 CHECK(!browser_version_string.empty()); |
| 1041 | 1020 |
| 1042 const bool log_gpu_control_list_decisions = | |
| 1043 CommandLine::ForCurrentProcess()->HasSwitch( | |
| 1044 switches::kLogGpuControlListDecisions); | |
| 1045 | |
| 1046 if (!gpu_blacklist_json.empty()) { | 1021 if (!gpu_blacklist_json.empty()) { |
| 1047 gpu_blacklist_.reset(gpu::GpuBlacklist::Create()); | 1022 gpu_blacklist_.reset(gpu::GpuBlacklist::Create()); |
| 1048 if (log_gpu_control_list_decisions) | |
| 1049 gpu_blacklist_->enable_control_list_logging("gpu_blacklist"); | |
| 1050 bool success = gpu_blacklist_->LoadList( | 1023 bool success = gpu_blacklist_->LoadList( |
| 1051 browser_version_string, gpu_blacklist_json, | 1024 browser_version_string, gpu_blacklist_json, |
| 1052 gpu::GpuControlList::kCurrentOsOnly); | 1025 gpu::GpuControlList::kCurrentOsOnly); |
| 1053 DCHECK(success); | 1026 DCHECK(success); |
| 1054 } | 1027 } |
| 1055 if (!gpu_switching_list_json.empty()) { | 1028 if (!gpu_switching_list_json.empty()) { |
| 1056 gpu_switching_list_.reset(gpu::GpuSwitchingList::Create()); | 1029 gpu_switching_list_.reset(gpu::GpuSwitchingList::Create()); |
| 1057 if (log_gpu_control_list_decisions) | |
| 1058 gpu_switching_list_->enable_control_list_logging("gpu_switching_list"); | |
| 1059 bool success = gpu_switching_list_->LoadList( | 1030 bool success = gpu_switching_list_->LoadList( |
| 1060 browser_version_string, gpu_switching_list_json, | 1031 browser_version_string, gpu_switching_list_json, |
| 1061 gpu::GpuControlList::kCurrentOsOnly); | 1032 gpu::GpuControlList::kCurrentOsOnly); |
| 1062 DCHECK(success); | 1033 DCHECK(success); |
| 1063 } | 1034 } |
| 1064 if (!gpu_driver_bug_list_json.empty()) { | 1035 if (!gpu_driver_bug_list_json.empty()) { |
| 1065 gpu_driver_bug_list_.reset(gpu::GpuDriverBugList::Create()); | 1036 gpu_driver_bug_list_.reset(gpu::GpuDriverBugList::Create()); |
| 1066 if (log_gpu_control_list_decisions) | |
| 1067 gpu_driver_bug_list_->enable_control_list_logging("gpu_driver_bug_list"); | |
| 1068 bool success = gpu_driver_bug_list_->LoadList( | 1037 bool success = gpu_driver_bug_list_->LoadList( |
| 1069 browser_version_string, gpu_driver_bug_list_json, | 1038 browser_version_string, gpu_driver_bug_list_json, |
| 1070 gpu::GpuControlList::kCurrentOsOnly); | 1039 gpu::GpuControlList::kCurrentOsOnly); |
| 1071 DCHECK(success); | 1040 DCHECK(success); |
| 1072 } | 1041 } |
| 1073 | 1042 |
| 1074 gpu_info_ = gpu_info; | 1043 gpu_info_ = gpu_info; |
| 1075 UpdateGpuInfo(gpu_info); | 1044 UpdateGpuInfo(gpu_info); |
| 1076 UpdateGpuSwitchingManager(gpu_info); | 1045 UpdateGpuSwitchingManager(gpu_info); |
| 1077 UpdatePreliminaryBlacklistedFeatures(); | 1046 UpdatePreliminaryBlacklistedFeatures(); |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1257 | 1226 |
| 1258 void GpuDataManagerImplPrivate::OnGpuProcessInitFailure() { | 1227 void GpuDataManagerImplPrivate::OnGpuProcessInitFailure() { |
| 1259 gpu_process_accessible_ = false; | 1228 gpu_process_accessible_ = false; |
| 1260 gpu_info_.finalized = true; | 1229 gpu_info_.finalized = true; |
| 1261 complete_gpu_info_already_requested_ = true; | 1230 complete_gpu_info_already_requested_ = true; |
| 1262 // Some observers might be waiting. | 1231 // Some observers might be waiting. |
| 1263 NotifyGpuInfoUpdate(); | 1232 NotifyGpuInfoUpdate(); |
| 1264 } | 1233 } |
| 1265 | 1234 |
| 1266 } // namespace content | 1235 } // namespace content |
| OLD | NEW |