Chromium Code Reviews| 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/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 for (std::set<int>::const_iterator it = list.begin(); | 208 for (std::set<int>::const_iterator it = list.begin(); |
| 209 it != list.end(); ++it) { | 209 it != list.end(); ++it) { |
| 210 if (!rt.empty()) | 210 if (!rt.empty()) |
| 211 rt += ","; | 211 rt += ","; |
| 212 rt += base::IntToString(*it); | 212 rt += base::IntToString(*it); |
| 213 } | 213 } |
| 214 return rt; | 214 return rt; |
| 215 } | 215 } |
| 216 | 216 |
| 217 #if defined(OS_MACOSX) | 217 #if defined(OS_MACOSX) |
| 218 void DisplayReconfigCallback(CGDirectDisplayID display, | 218 void DisplayReconfigCallback(CGDirectDisplayID display, |
|
danakj
2016/04/05 01:01:03
Restored this.
| |
| 219 CGDisplayChangeSummaryFlags flags, | 219 CGDisplayChangeSummaryFlags flags, |
| 220 void* gpu_data_manager) { | 220 void* gpu_data_manager) { |
| 221 if (flags == kCGDisplayBeginConfigurationFlag) | 221 if (flags == kCGDisplayBeginConfigurationFlag) |
| 222 return; // This call contains no information about the display change | 222 return; // This call contains no information about the display change |
| 223 | 223 |
| 224 GpuDataManagerImpl* manager = | 224 GpuDataManagerImpl* manager = |
| 225 reinterpret_cast<GpuDataManagerImpl*>(gpu_data_manager); | 225 reinterpret_cast<GpuDataManagerImpl*>(gpu_data_manager); |
| 226 DCHECK(manager); | 226 DCHECK(manager); |
| 227 | 227 |
| 228 // Display change. | |
| 229 bool display_changed = false; | |
| 230 uint32_t displayCount; | |
| 231 CGGetActiveDisplayList(0, NULL, &displayCount); | |
| 232 if (displayCount != manager->GetDisplayCount()) { | |
| 233 manager->SetDisplayCount(displayCount); | |
| 234 display_changed = true; | |
| 235 } | |
| 236 | |
| 237 // Gpu change. | |
| 238 bool gpu_changed = false; | 228 bool gpu_changed = false; |
| 239 if (flags & kCGDisplayAddFlag) { | 229 if (flags & kCGDisplayAddFlag) { |
| 240 uint32_t vendor_id, device_id; | 230 uint32_t vendor_id, device_id; |
| 241 if (gpu::CollectGpuID(&vendor_id, &device_id) == gpu::kCollectInfoSuccess) { | 231 if (gpu::CollectGpuID(&vendor_id, &device_id) == gpu::kCollectInfoSuccess) { |
| 242 gpu_changed = manager->UpdateActiveGpu(vendor_id, device_id); | 232 gpu_changed = manager->UpdateActiveGpu(vendor_id, device_id); |
| 243 } | 233 } |
| 244 } | 234 } |
| 245 | 235 |
| 246 if (display_changed || gpu_changed) | 236 if (gpu_changed) |
| 247 manager->HandleGpuSwitch(); | 237 manager->HandleGpuSwitch(); |
| 248 } | 238 } |
| 249 #endif // OS_MACOSX | 239 #endif // OS_MACOSX |
| 250 | 240 |
| 251 // Block all domains' use of 3D APIs for this many milliseconds if | 241 // Block all domains' use of 3D APIs for this many milliseconds if |
| 252 // approaching a threshold where system stability might be compromised. | 242 // approaching a threshold where system stability might be compromised. |
| 253 const int64_t kBlockAllDomainsMs = 10000; | 243 const int64_t kBlockAllDomainsMs = 10000; |
| 254 const int kNumResetsWithinDuration = 1; | 244 const int kNumResetsWithinDuration = 1; |
| 255 | 245 |
| 256 // Enums for UMA histograms. | 246 // Enums for UMA histograms. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 297 bool GpuDataManagerImplPrivate::IsDriverBugWorkaroundActive(int feature) const { | 287 bool GpuDataManagerImplPrivate::IsDriverBugWorkaroundActive(int feature) const { |
| 298 return (gpu_driver_bugs_.count(feature) == 1); | 288 return (gpu_driver_bugs_.count(feature) == 1); |
| 299 } | 289 } |
| 300 | 290 |
| 301 size_t GpuDataManagerImplPrivate::GetBlacklistedFeatureCount() const { | 291 size_t GpuDataManagerImplPrivate::GetBlacklistedFeatureCount() const { |
| 302 if (use_swiftshader_) | 292 if (use_swiftshader_) |
| 303 return 1; | 293 return 1; |
| 304 return blacklisted_features_.size(); | 294 return blacklisted_features_.size(); |
| 305 } | 295 } |
| 306 | 296 |
| 307 void GpuDataManagerImplPrivate::SetDisplayCount(unsigned int display_count) { | |
| 308 display_count_ = display_count; | |
| 309 } | |
| 310 | |
| 311 unsigned int GpuDataManagerImplPrivate::GetDisplayCount() const { | |
| 312 return display_count_; | |
| 313 } | |
| 314 | |
| 315 gpu::GPUInfo GpuDataManagerImplPrivate::GetGPUInfo() const { | 297 gpu::GPUInfo GpuDataManagerImplPrivate::GetGPUInfo() const { |
| 316 return gpu_info_; | 298 return gpu_info_; |
| 317 } | 299 } |
| 318 | 300 |
| 319 void GpuDataManagerImplPrivate::GetGpuProcessHandles( | 301 void GpuDataManagerImplPrivate::GetGpuProcessHandles( |
| 320 const GpuDataManager::GetGpuProcessHandlesCallback& callback) const { | 302 const GpuDataManager::GetGpuProcessHandlesCallback& callback) const { |
| 321 GpuProcessHost::GetProcessHandles(callback); | 303 GpuProcessHost::GetProcessHandles(callback); |
| 322 } | 304 } |
| 323 | 305 |
| 324 bool GpuDataManagerImplPrivate::GpuAccessAllowed( | 306 bool GpuDataManagerImplPrivate::GpuAccessAllowed( |
| (...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 993 | 975 |
| 994 GpuDataManagerImplPrivate::GpuDataManagerImplPrivate(GpuDataManagerImpl* owner) | 976 GpuDataManagerImplPrivate::GpuDataManagerImplPrivate(GpuDataManagerImpl* owner) |
| 995 : complete_gpu_info_already_requested_(false), | 977 : complete_gpu_info_already_requested_(false), |
| 996 observer_list_(new GpuDataManagerObserverList), | 978 observer_list_(new GpuDataManagerObserverList), |
| 997 use_swiftshader_(false), | 979 use_swiftshader_(false), |
| 998 card_blacklisted_(false), | 980 card_blacklisted_(false), |
| 999 update_histograms_(true), | 981 update_histograms_(true), |
| 1000 window_count_(0), | 982 window_count_(0), |
| 1001 domain_blocking_enabled_(true), | 983 domain_blocking_enabled_(true), |
| 1002 owner_(owner), | 984 owner_(owner), |
| 1003 display_count_(0), | |
| 1004 gpu_process_accessible_(true), | 985 gpu_process_accessible_(true), |
| 1005 is_initialized_(false), | 986 is_initialized_(false), |
| 1006 finalized_(false) { | 987 finalized_(false) { |
| 1007 DCHECK(owner_); | 988 DCHECK(owner_); |
| 1008 const base::CommandLine* command_line = | 989 const base::CommandLine* command_line = |
| 1009 base::CommandLine::ForCurrentProcess(); | 990 base::CommandLine::ForCurrentProcess(); |
| 1010 swiftshader_path_ = | 991 swiftshader_path_ = |
| 1011 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( | 992 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( |
| 1012 switches::kSwiftShaderPath); | 993 switches::kSwiftShaderPath); |
| 1013 if (command_line->HasSwitch(switches::kDisableGpu)) | 994 if (command_line->HasSwitch(switches::kDisableGpu)) |
| 1014 DisableHardwareAcceleration(); | 995 DisableHardwareAcceleration(); |
| 1015 | 996 |
| 1016 #if defined(OS_MACOSX) | 997 #if defined(OS_MACOSX) |
| 1017 CGGetActiveDisplayList (0, NULL, &display_count_); | |
| 1018 CGDisplayRegisterReconfigurationCallback(DisplayReconfigCallback, owner_); | 998 CGDisplayRegisterReconfigurationCallback(DisplayReconfigCallback, owner_); |
| 1019 #endif // OS_MACOSX | 999 #endif // OS_MACOSX |
| 1020 | 1000 |
| 1021 // For testing only. | 1001 // For testing only. |
| 1022 if (command_line->HasSwitch(switches::kDisableDomainBlockingFor3DAPIs)) { | 1002 if (command_line->HasSwitch(switches::kDisableDomainBlockingFor3DAPIs)) { |
| 1023 domain_blocking_enabled_ = false; | 1003 domain_blocking_enabled_ = false; |
| 1024 } | 1004 } |
| 1025 } | 1005 } |
| 1026 | 1006 |
| 1027 GpuDataManagerImplPrivate::~GpuDataManagerImplPrivate() { | 1007 GpuDataManagerImplPrivate::~GpuDataManagerImplPrivate() { |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1234 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure; | 1214 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure; |
| 1235 #if defined(OS_WIN) | 1215 #if defined(OS_WIN) |
| 1236 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure; | 1216 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure; |
| 1237 #endif | 1217 #endif |
| 1238 complete_gpu_info_already_requested_ = true; | 1218 complete_gpu_info_already_requested_ = true; |
| 1239 // Some observers might be waiting. | 1219 // Some observers might be waiting. |
| 1240 NotifyGpuInfoUpdate(); | 1220 NotifyGpuInfoUpdate(); |
| 1241 } | 1221 } |
| 1242 | 1222 |
| 1243 } // namespace content | 1223 } // namespace content |
| OLD | NEW |