| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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.h" | 5 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 6 | 6 |
| 7 #if defined(OS_MACOSX) | 7 #if defined(OS_MACOSX) |
| 8 #include <ApplicationServices/ApplicationServices.h> | 8 #include <ApplicationServices/ApplicationServices.h> |
| 9 #endif // OS_MACOSX | 9 #endif // OS_MACOSX |
| 10 | 10 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 CGDisplayRegisterReconfigurationCallback(DisplayReconfigCallback, this); | 125 CGDisplayRegisterReconfigurationCallback(DisplayReconfigCallback, this); |
| 126 #endif // OS_MACOSX | 126 #endif // OS_MACOSX |
| 127 } | 127 } |
| 128 | 128 |
| 129 void GpuDataManagerImpl::Initialize() { | 129 void GpuDataManagerImpl::Initialize() { |
| 130 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 130 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 131 if (command_line->HasSwitch(switches::kSkipGpuDataLoading)) | 131 if (command_line->HasSwitch(switches::kSkipGpuDataLoading)) |
| 132 return; | 132 return; |
| 133 | 133 |
| 134 GPUInfo gpu_info; | 134 GPUInfo gpu_info; |
| 135 gpu_info_collector::CollectPreliminaryGraphicsInfo(&gpu_info); | 135 gpu_info_collector::CollectBasicGraphicsInfo(&gpu_info); |
| 136 #if defined(ARCH_CPU_X86_FAMILY) | 136 #if defined(ARCH_CPU_X86_FAMILY) |
| 137 if (!gpu_info.gpu.vendor_id || !gpu_info.gpu.device_id) | 137 if (!gpu_info.gpu.vendor_id || !gpu_info.gpu.device_id) |
| 138 gpu_info.finalized = true; | 138 gpu_info.finalized = true; |
| 139 #endif | 139 #endif |
| 140 | 140 |
| 141 std::string gpu_blacklist_string; | 141 std::string gpu_blacklist_string; |
| 142 if (!command_line->HasSwitch(switches::kIgnoreGpuBlacklist)) { | 142 if (!command_line->HasSwitch(switches::kIgnoreGpuBlacklist)) { |
| 143 const base::StringPiece gpu_blacklist_json = | 143 const base::StringPiece gpu_blacklist_json = |
| 144 GetContentClient()->GetDataResource( | 144 GetContentClient()->GetDataResource( |
| 145 IDR_GPU_BLACKLIST, ui::SCALE_FACTOR_NONE); | 145 IDR_GPU_BLACKLIST, ui::SCALE_FACTOR_NONE); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 166 GetContentClient()->GetProduct()); | 166 GetContentClient()->GetProduct()); |
| 167 CHECK(!browser_version_string.empty()); | 167 CHECK(!browser_version_string.empty()); |
| 168 gpu_blacklist_.reset(new GpuBlacklist()); | 168 gpu_blacklist_.reset(new GpuBlacklist()); |
| 169 bool succeed = gpu_blacklist_->LoadGpuBlacklist( | 169 bool succeed = gpu_blacklist_->LoadGpuBlacklist( |
| 170 browser_version_string, | 170 browser_version_string, |
| 171 gpu_blacklist_json, | 171 gpu_blacklist_json, |
| 172 GpuBlacklist::kCurrentOsOnly); | 172 GpuBlacklist::kCurrentOsOnly); |
| 173 CHECK(succeed); | 173 CHECK(succeed); |
| 174 } | 174 } |
| 175 | 175 |
| 176 { |
| 177 base::AutoLock auto_lock(gpu_info_lock_); |
| 178 gpu_info_ = gpu_info; |
| 179 } |
| 176 UpdateGpuInfo(gpu_info); | 180 UpdateGpuInfo(gpu_info); |
| 177 UpdateGpuSwitchingManager(gpu_info); | 181 UpdateGpuSwitchingManager(gpu_info); |
| 178 UpdatePreliminaryBlacklistedFeatures(); | 182 UpdatePreliminaryBlacklistedFeatures(); |
| 179 } | 183 } |
| 180 | 184 |
| 181 GpuDataManagerImpl::~GpuDataManagerImpl() { | 185 GpuDataManagerImpl::~GpuDataManagerImpl() { |
| 182 #if defined(OS_MACOSX) | 186 #if defined(OS_MACOSX) |
| 183 CGDisplayRemoveReconfigurationCallback(DisplayReconfigCallback, this); | 187 CGDisplayRemoveReconfigurationCallback(DisplayReconfigCallback, this); |
| 184 #endif | 188 #endif |
| 185 } | 189 } |
| 186 | 190 |
| 187 void GpuDataManagerImpl::RequestCompleteGpuInfoIfNeeded() { | 191 void GpuDataManagerImpl::RequestCompleteGpuInfoIfNeeded() { |
| 188 if (complete_gpu_info_already_requested_ || gpu_info_.finalized) | 192 if (complete_gpu_info_already_requested_ || gpu_info_.finalized) |
| 189 return; | 193 return; |
| 190 complete_gpu_info_already_requested_ = true; | 194 complete_gpu_info_already_requested_ = true; |
| 191 | 195 |
| 192 GpuProcessHost::SendOnIO( | 196 GpuProcessHost::SendOnIO( |
| 197 #if defined(OS_WIN) |
| 193 GpuProcessHost::GPU_PROCESS_KIND_UNSANDBOXED, | 198 GpuProcessHost::GPU_PROCESS_KIND_UNSANDBOXED, |
| 199 #else |
| 200 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, |
| 201 #endif |
| 194 CAUSE_FOR_GPU_LAUNCH_GPUDATAMANAGER_REQUESTCOMPLETEGPUINFOIFNEEDED, | 202 CAUSE_FOR_GPU_LAUNCH_GPUDATAMANAGER_REQUESTCOMPLETEGPUINFOIFNEEDED, |
| 195 new GpuMsg_CollectGraphicsInfo()); | 203 new GpuMsg_CollectGraphicsInfo()); |
| 196 } | 204 } |
| 197 | 205 |
| 198 bool GpuDataManagerImpl::IsCompleteGpuInfoAvailable() const { | 206 bool GpuDataManagerImpl::IsCompleteGpuInfoAvailable() const { |
| 199 return gpu_info_.finalized; | 207 return gpu_info_.finalized; |
| 200 } | 208 } |
| 201 | 209 |
| 202 void GpuDataManagerImpl::UpdateGpuInfo(const GPUInfo& gpu_info) { | 210 void GpuDataManagerImpl::UpdateGpuInfo(const GPUInfo& gpu_info) { |
| 203 // No further update of gpu_info if falling back to software renderer. | 211 // No further update of gpu_info if falling back to software renderer. |
| 204 if (software_rendering_) | 212 if (software_rendering_) |
| 205 return; | 213 return; |
| 206 | 214 |
| 207 GetContentClient()->SetGpuInfo(gpu_info); | 215 GPUInfo my_gpu_info; |
| 216 { |
| 217 base::AutoLock auto_lock(gpu_info_lock_); |
| 218 gpu_info_collector::MergeGPUInfo(&gpu_info_, gpu_info); |
| 219 complete_gpu_info_already_requested_ = |
| 220 complete_gpu_info_already_requested_ || gpu_info_.finalized; |
| 221 my_gpu_info = gpu_info_; |
| 222 } |
| 223 |
| 224 GetContentClient()->SetGpuInfo(my_gpu_info); |
| 208 | 225 |
| 209 if (gpu_blacklist_.get()) { | 226 if (gpu_blacklist_.get()) { |
| 210 GpuBlacklist::Decision decision = | 227 GpuBlacklist::Decision decision = |
| 211 gpu_blacklist_->MakeBlacklistDecision( | 228 gpu_blacklist_->MakeBlacklistDecision( |
| 212 GpuBlacklist::kOsAny, "", gpu_info); | 229 GpuBlacklist::kOsAny, "", my_gpu_info); |
| 213 if (update_histograms_) | 230 if (update_histograms_) |
| 214 UpdateStats(gpu_blacklist_.get(), decision.blacklisted_features); | 231 UpdateStats(gpu_blacklist_.get(), decision.blacklisted_features); |
| 215 | 232 |
| 216 UpdateBlacklistedFeatures(decision.blacklisted_features); | 233 UpdateBlacklistedFeatures(decision.blacklisted_features); |
| 217 if (decision.gpu_switching != GPU_SWITCHING_OPTION_UNKNOWN) { | 234 if (decision.gpu_switching != GPU_SWITCHING_OPTION_UNKNOWN) { |
| 218 // Blacklist decision should not overwrite commandline switch from users. | 235 // Blacklist decision should not overwrite commandline switch from users. |
| 219 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 236 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 220 if (!command_line->HasSwitch(switches::kGpuSwitching)) | 237 if (!command_line->HasSwitch(switches::kGpuSwitching)) |
| 221 gpu_switching_ = decision.gpu_switching; | 238 gpu_switching_ = decision.gpu_switching; |
| 222 } | 239 } |
| 223 } | 240 } |
| 224 | 241 |
| 225 { | |
| 226 base::AutoLock auto_lock(gpu_info_lock_); | |
| 227 gpu_info_ = gpu_info; | |
| 228 complete_gpu_info_already_requested_ = | |
| 229 complete_gpu_info_already_requested_ || gpu_info_.finalized; | |
| 230 } | |
| 231 | |
| 232 // We have to update GpuFeatureType before notify all the observers. | 242 // We have to update GpuFeatureType before notify all the observers. |
| 233 NotifyGpuInfoUpdate(); | 243 NotifyGpuInfoUpdate(); |
| 234 } | 244 } |
| 235 | 245 |
| 236 GPUInfo GpuDataManagerImpl::GetGPUInfo() const { | 246 GPUInfo GpuDataManagerImpl::GetGPUInfo() const { |
| 237 GPUInfo gpu_info; | 247 GPUInfo gpu_info; |
| 238 { | 248 { |
| 239 base::AutoLock auto_lock(gpu_info_lock_); | 249 base::AutoLock auto_lock(gpu_info_lock_); |
| 240 gpu_info = gpu_info_; | 250 gpu_info = gpu_info_; |
| 241 } | 251 } |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 switches::kGpuSwitchingOptionNameForceIntegrated); | 473 switches::kGpuSwitchingOptionNameForceIntegrated); |
| 464 break; | 474 break; |
| 465 case GPU_SWITCHING_OPTION_AUTOMATIC: | 475 case GPU_SWITCHING_OPTION_AUTOMATIC: |
| 466 case GPU_SWITCHING_OPTION_UNKNOWN: | 476 case GPU_SWITCHING_OPTION_UNKNOWN: |
| 467 break; | 477 break; |
| 468 } | 478 } |
| 469 } else { | 479 } else { |
| 470 command_line->AppendSwitchASCII(switches::kSupportsDualGpus, "false"); | 480 command_line->AppendSwitchASCII(switches::kSupportsDualGpus, "false"); |
| 471 } | 481 } |
| 472 | 482 |
| 473 if (!gpu_blacklist_.get() || !gpu_blacklist_->needs_more_info()) | |
| 474 command_line->AppendSwitch(switches::kSkipGpuFullInfoCollection); | |
| 475 | |
| 476 if (!swiftshader_path.empty()) | 483 if (!swiftshader_path.empty()) |
| 477 command_line->AppendSwitchPath(switches::kSwiftShaderPath, | 484 command_line->AppendSwitchPath(switches::kSwiftShaderPath, |
| 478 swiftshader_path); | 485 swiftshader_path); |
| 479 | 486 |
| 480 { | 487 { |
| 481 base::AutoLock auto_lock(gpu_info_lock_); | 488 base::AutoLock auto_lock(gpu_info_lock_); |
| 482 if (gpu_info_.optimus) | 489 if (gpu_info_.optimus) |
| 483 command_line->AppendSwitch(switches::kReduceGpuSandbox); | 490 command_line->AppendSwitch(switches::kReduceGpuSandbox); |
| 484 if (gpu_info_.amd_switchable) { | 491 if (gpu_info_.amd_switchable) { |
| 485 // The image transport surface currently doesn't work with AMD Dynamic | 492 // The image transport surface currently doesn't work with AMD Dynamic |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 BLOCK_STATUS_MAX); | 729 BLOCK_STATUS_MAX); |
| 723 | 730 |
| 724 return DOMAIN_BLOCK_STATUS_NOT_BLOCKED; | 731 return DOMAIN_BLOCK_STATUS_NOT_BLOCKED; |
| 725 } | 732 } |
| 726 | 733 |
| 727 int64 GpuDataManagerImpl::GetBlockAllDomainsDurationInMs() const { | 734 int64 GpuDataManagerImpl::GetBlockAllDomainsDurationInMs() const { |
| 728 return kBlockAllDomainsMs; | 735 return kBlockAllDomainsMs; |
| 729 } | 736 } |
| 730 | 737 |
| 731 } // namespace content | 738 } // namespace content |
| OLD | NEW |