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 | |
338 InitializeImpl(gpu_blacklist_json, std::string(), std::string(), gpu_info); | 335 InitializeImpl(gpu_blacklist_json, std::string(), std::string(), gpu_info); |
339 } | 336 } |
340 | 337 |
341 bool GpuDataManagerImplPrivate::IsFeatureBlacklisted(int feature) const { | 338 bool GpuDataManagerImplPrivate::IsFeatureBlacklisted(int feature) const { |
342 #if defined(OS_CHROMEOS) | 339 #if defined(OS_CHROMEOS) |
343 if (feature == gpu::GPU_FEATURE_TYPE_PANEL_FITTING && | 340 if (feature == gpu::GPU_FEATURE_TYPE_PANEL_FITTING && |
344 CommandLine::ForCurrentProcess()->HasSwitch( | 341 CommandLine::ForCurrentProcess()->HasSwitch( |
345 switches::kDisablePanelFitting)) { | 342 switches::kDisablePanelFitting)) { |
346 return true; | 343 return true; |
347 } | 344 } |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 std::string* gl_version) { | 538 std::string* gl_version) { |
542 DCHECK(gl_vendor && gl_renderer && gl_version); | 539 DCHECK(gl_vendor && gl_renderer && gl_version); |
543 | 540 |
544 *gl_vendor = gpu_info_.gl_vendor; | 541 *gl_vendor = gpu_info_.gl_vendor; |
545 *gl_renderer = gpu_info_.gl_renderer; | 542 *gl_renderer = gpu_info_.gl_renderer; |
546 *gl_version = gpu_info_.gl_version_string; | 543 *gl_version = gpu_info_.gl_version_string; |
547 } | 544 } |
548 | 545 |
549 void GpuDataManagerImplPrivate::Initialize() { | 546 void GpuDataManagerImplPrivate::Initialize() { |
550 TRACE_EVENT0("startup", "GpuDataManagerImpl::Initialize"); | 547 TRACE_EVENT0("startup", "GpuDataManagerImpl::Initialize"); |
551 if (finalized_) { | 548 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
552 DLOG(INFO) << "GpuDataManagerImpl marked as finalized; skipping Initialize"; | 549 if (command_line->HasSwitch(switches::kSkipGpuDataLoading) && |
553 return; | 550 !command_line->HasSwitch(switches::kUseGpuInTests)) |
554 } | |
555 | |
556 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
557 if (command_line->HasSwitch(switches::kSkipGpuDataLoading)) | |
558 return; | 551 return; |
559 | 552 |
560 gpu::GPUInfo gpu_info; | 553 gpu::GPUInfo gpu_info; |
561 if (command_line->GetSwitchValueASCII( | 554 { |
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 { | |
580 TRACE_EVENT0("startup", | 555 TRACE_EVENT0("startup", |
581 "GpuDataManagerImpl::Initialize:CollectBasicGraphicsInfo"); | 556 "GpuDataManagerImpl::Initialize:CollectBasicGraphicsInfo"); |
582 gpu::CollectBasicGraphicsInfo(&gpu_info); | 557 gpu::CollectBasicGraphicsInfo(&gpu_info); |
583 } | 558 } |
584 #if defined(ARCH_CPU_X86_FAMILY) | 559 #if defined(ARCH_CPU_X86_FAMILY) |
585 if (!gpu_info.gpu.vendor_id || !gpu_info.gpu.device_id) | 560 if (!gpu_info.gpu.vendor_id || !gpu_info.gpu.device_id) |
586 gpu_info.finalized = true; | 561 gpu_info.finalized = true; |
587 #endif | 562 #endif |
588 | 563 |
589 std::string gpu_blacklist_string; | 564 std::string gpu_blacklist_string; |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1003 gpu_switching_(gpu::GPU_SWITCHING_OPTION_AUTOMATIC), | 978 gpu_switching_(gpu::GPU_SWITCHING_OPTION_AUTOMATIC), |
1004 observer_list_(new GpuDataManagerObserverList), | 979 observer_list_(new GpuDataManagerObserverList), |
1005 use_swiftshader_(false), | 980 use_swiftshader_(false), |
1006 card_blacklisted_(false), | 981 card_blacklisted_(false), |
1007 update_histograms_(true), | 982 update_histograms_(true), |
1008 window_count_(0), | 983 window_count_(0), |
1009 domain_blocking_enabled_(true), | 984 domain_blocking_enabled_(true), |
1010 owner_(owner), | 985 owner_(owner), |
1011 display_count_(0), | 986 display_count_(0), |
1012 gpu_process_accessible_(true), | 987 gpu_process_accessible_(true), |
1013 use_software_compositor_(false), | 988 use_software_compositor_(false) { |
1014 finalized_(false) { | |
1015 DCHECK(owner_); | 989 DCHECK(owner_); |
1016 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 990 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
1017 if (command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) { | 991 if (command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) { |
1018 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas); | 992 command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas); |
1019 command_line->AppendSwitch(switches::kDisableAcceleratedLayers); | 993 command_line->AppendSwitch(switches::kDisableAcceleratedLayers); |
1020 } | 994 } |
1021 if (command_line->HasSwitch(switches::kDisableGpu)) | 995 if (command_line->HasSwitch(switches::kDisableGpu)) |
1022 DisableHardwareAcceleration(); | 996 DisableHardwareAcceleration(); |
1023 if (command_line->HasSwitch(switches::kEnableSoftwareCompositing)) | 997 if (command_line->HasSwitch(switches::kEnableSoftwareCompositing)) |
1024 use_software_compositor_ = true; | 998 use_software_compositor_ = true; |
(...skipping 26 matching lines...) Expand all Loading... |
1051 const std::string& gpu_blacklist_json, | 1025 const std::string& gpu_blacklist_json, |
1052 const std::string& gpu_switching_list_json, | 1026 const std::string& gpu_switching_list_json, |
1053 const std::string& gpu_driver_bug_list_json, | 1027 const std::string& gpu_driver_bug_list_json, |
1054 const gpu::GPUInfo& gpu_info) { | 1028 const gpu::GPUInfo& gpu_info) { |
1055 std::string browser_version_string = ProcessVersionString( | 1029 std::string browser_version_string = ProcessVersionString( |
1056 GetContentClient()->GetProduct()); | 1030 GetContentClient()->GetProduct()); |
1057 CHECK(!browser_version_string.empty()); | 1031 CHECK(!browser_version_string.empty()); |
1058 | 1032 |
1059 if (!gpu_blacklist_json.empty()) { | 1033 if (!gpu_blacklist_json.empty()) { |
1060 gpu_blacklist_.reset(gpu::GpuBlacklist::Create()); | 1034 gpu_blacklist_.reset(gpu::GpuBlacklist::Create()); |
1061 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
1062 switches::kLogGpuControlListDecisions)) { | |
1063 gpu_blacklist_->enable_control_list_logging(); | |
1064 } | |
1065 gpu_blacklist_->LoadList( | 1035 gpu_blacklist_->LoadList( |
1066 browser_version_string, gpu_blacklist_json, | 1036 browser_version_string, gpu_blacklist_json, |
1067 gpu::GpuControlList::kCurrentOsOnly); | 1037 gpu::GpuControlList::kCurrentOsOnly); |
1068 } | 1038 } |
1069 if (!gpu_switching_list_json.empty()) { | 1039 if (!gpu_switching_list_json.empty()) { |
1070 gpu_switching_list_.reset(gpu::GpuSwitchingList::Create()); | 1040 gpu_switching_list_.reset(gpu::GpuSwitchingList::Create()); |
1071 gpu_switching_list_->LoadList( | 1041 gpu_switching_list_->LoadList( |
1072 browser_version_string, gpu_switching_list_json, | 1042 browser_version_string, gpu_switching_list_json, |
1073 gpu::GpuControlList::kCurrentOsOnly); | 1043 gpu::GpuControlList::kCurrentOsOnly); |
1074 } | 1044 } |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1265 | 1235 |
1266 void GpuDataManagerImplPrivate::OnGpuProcessInitFailure() { | 1236 void GpuDataManagerImplPrivate::OnGpuProcessInitFailure() { |
1267 gpu_process_accessible_ = false; | 1237 gpu_process_accessible_ = false; |
1268 gpu_info_.finalized = true; | 1238 gpu_info_.finalized = true; |
1269 complete_gpu_info_already_requested_ = true; | 1239 complete_gpu_info_already_requested_ = true; |
1270 // Some observers might be waiting. | 1240 // Some observers might be waiting. |
1271 NotifyGpuInfoUpdate(); | 1241 NotifyGpuInfoUpdate(); |
1272 } | 1242 } |
1273 | 1243 |
1274 } // namespace content | 1244 } // namespace content |
OLD | NEW |