| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 *reason = "GPU access is disabled "; | 358 *reason = "GPU access is disabled "; |
| 359 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 359 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 360 if (command_line->HasSwitch(switches::kDisableGpu)) | 360 if (command_line->HasSwitch(switches::kDisableGpu)) |
| 361 *reason += "through commandline switch --disable-gpu."; | 361 *reason += "through commandline switch --disable-gpu."; |
| 362 else | 362 else |
| 363 *reason += "in chrome://settings."; | 363 *reason += "in chrome://settings."; |
| 364 } | 364 } |
| 365 return false; | 365 return false; |
| 366 } | 366 } |
| 367 | 367 |
| 368 // We only need to block GPU process if more features are disallowed other | 368 if (preliminary_blacklisted_features_initialized_) { |
| 369 // than those in the preliminary gpu feature flags because the latter work | 369 // We only need to block GPU process if more features are disallowed other |
| 370 // through renderer commandline switches. WebGL and WebGL2 should not matter | 370 // than those in the preliminary gpu feature flags because the latter work |
| 371 // because their context creation can always be rejected on the GPU process | 371 // through renderer commandline switches. WebGL and WebGL2 should not matter |
| 372 // side. | 372 // because their context creation can always be rejected on the GPU process |
| 373 std::set<int> feature_diffs; | 373 // side. |
| 374 std::set_difference(blacklisted_features_.begin(), | 374 std::set<int> feature_diffs; |
| 375 blacklisted_features_.end(), | 375 std::set_difference(blacklisted_features_.begin(), |
| 376 preliminary_blacklisted_features_.begin(), | 376 blacklisted_features_.end(), |
| 377 preliminary_blacklisted_features_.end(), | 377 preliminary_blacklisted_features_.begin(), |
| 378 std::inserter(feature_diffs, feature_diffs.begin())); | 378 preliminary_blacklisted_features_.end(), |
| 379 if (feature_diffs.size()) { | 379 std::inserter(feature_diffs, feature_diffs.begin())); |
| 380 // TODO(zmo): Other features might also be OK to ignore here. | 380 if (feature_diffs.size()) { |
| 381 feature_diffs.erase(gpu::GPU_FEATURE_TYPE_WEBGL); | 381 // TODO(zmo): Other features might also be OK to ignore here. |
| 382 feature_diffs.erase(gpu::GPU_FEATURE_TYPE_WEBGL2); | 382 feature_diffs.erase(gpu::GPU_FEATURE_TYPE_WEBGL); |
| 383 } | 383 feature_diffs.erase(gpu::GPU_FEATURE_TYPE_WEBGL2); |
| 384 if (feature_diffs.size()) { | |
| 385 if (reason) { | |
| 386 *reason = "Features are disabled on full but not preliminary GPU info."; | |
| 387 } | 384 } |
| 388 return false; | 385 if (feature_diffs.size()) { |
| 386 if (reason) { |
| 387 *reason = "Features are disabled on full but not preliminary GPU info."; |
| 388 } |
| 389 return false; |
| 390 } |
| 389 } | 391 } |
| 390 | 392 |
| 391 if (blacklisted_features_.size() == gpu::NUMBER_OF_GPU_FEATURE_TYPES) { | 393 if (blacklisted_features_.size() == gpu::NUMBER_OF_GPU_FEATURE_TYPES) { |
| 392 // On Linux, we use cached GL strings to make blacklist decsions at browser | 394 // On Linux, we use cached GL strings to make blacklist decsions at browser |
| 393 // startup time. We need to launch the GPU process to validate these | 395 // startup time. We need to launch the GPU process to validate these |
| 394 // strings even if all features are blacklisted. If all GPU features are | 396 // strings even if all features are blacklisted. If all GPU features are |
| 395 // disabled, the GPU process will only initialize GL bindings, create a GL | 397 // disabled, the GPU process will only initialize GL bindings, create a GL |
| 396 // context, and collect full GPU info. | 398 // context, and collect full GPU info. |
| 397 #if !defined(OS_LINUX) | 399 #if !defined(OS_LINUX) |
| 398 if (reason) { | 400 if (reason) { |
| (...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1128 } | 1130 } |
| 1129 | 1131 |
| 1130 // static | 1132 // static |
| 1131 GpuDataManagerImplPrivate* GpuDataManagerImplPrivate::Create( | 1133 GpuDataManagerImplPrivate* GpuDataManagerImplPrivate::Create( |
| 1132 GpuDataManagerImpl* owner) { | 1134 GpuDataManagerImpl* owner) { |
| 1133 return new GpuDataManagerImplPrivate(owner); | 1135 return new GpuDataManagerImplPrivate(owner); |
| 1134 } | 1136 } |
| 1135 | 1137 |
| 1136 GpuDataManagerImplPrivate::GpuDataManagerImplPrivate(GpuDataManagerImpl* owner) | 1138 GpuDataManagerImplPrivate::GpuDataManagerImplPrivate(GpuDataManagerImpl* owner) |
| 1137 : complete_gpu_info_already_requested_(false), | 1139 : complete_gpu_info_already_requested_(false), |
| 1140 preliminary_blacklisted_features_initialized_(false), |
| 1138 observer_list_(new GpuDataManagerObserverList), | 1141 observer_list_(new GpuDataManagerObserverList), |
| 1139 use_swiftshader_(false), | 1142 use_swiftshader_(false), |
| 1140 card_blacklisted_(false), | 1143 card_blacklisted_(false), |
| 1141 update_histograms_(true), | 1144 update_histograms_(true), |
| 1142 domain_blocking_enabled_(true), | 1145 domain_blocking_enabled_(true), |
| 1143 owner_(owner), | 1146 owner_(owner), |
| 1144 gpu_process_accessible_(true), | 1147 gpu_process_accessible_(true), |
| 1145 is_initialized_(false), | 1148 is_initialized_(false), |
| 1146 finalized_(false), | 1149 finalized_(false), |
| 1147 in_process_gpu_(false) { | 1150 in_process_gpu_(false) { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1225 if (card_blacklisted_) { | 1228 if (card_blacklisted_) { |
| 1226 blacklisted_features_.insert(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING); | 1229 blacklisted_features_.insert(gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING); |
| 1227 blacklisted_features_.insert(gpu::GPU_FEATURE_TYPE_WEBGL); | 1230 blacklisted_features_.insert(gpu::GPU_FEATURE_TYPE_WEBGL); |
| 1228 } | 1231 } |
| 1229 | 1232 |
| 1230 EnableSwiftShaderIfNecessary(); | 1233 EnableSwiftShaderIfNecessary(); |
| 1231 } | 1234 } |
| 1232 | 1235 |
| 1233 void GpuDataManagerImplPrivate::UpdatePreliminaryBlacklistedFeatures() { | 1236 void GpuDataManagerImplPrivate::UpdatePreliminaryBlacklistedFeatures() { |
| 1234 preliminary_blacklisted_features_ = blacklisted_features_; | 1237 preliminary_blacklisted_features_ = blacklisted_features_; |
| 1238 preliminary_blacklisted_features_initialized_ = true; |
| 1235 } | 1239 } |
| 1236 | 1240 |
| 1237 void GpuDataManagerImplPrivate::UpdateGpuSwitchingManager( | 1241 void GpuDataManagerImplPrivate::UpdateGpuSwitchingManager( |
| 1238 const gpu::GPUInfo& gpu_info) { | 1242 const gpu::GPUInfo& gpu_info) { |
| 1239 // The vendor IDs might be 0 on non-PCI devices (like Android), but | 1243 // The vendor IDs might be 0 on non-PCI devices (like Android), but |
| 1240 // the length of the vector is all we care about in most cases. | 1244 // the length of the vector is all we care about in most cases. |
| 1241 std::vector<uint32_t> vendor_ids; | 1245 std::vector<uint32_t> vendor_ids; |
| 1242 vendor_ids.push_back(gpu_info.gpu.vendor_id); | 1246 vendor_ids.push_back(gpu_info.gpu.vendor_id); |
| 1243 for (const auto& device : gpu_info.secondary_gpus) { | 1247 for (const auto& device : gpu_info.secondary_gpus) { |
| 1244 vendor_ids.push_back(device.vendor_id); | 1248 vendor_ids.push_back(device.vendor_id); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1367 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure; | 1371 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure; |
| 1368 #if defined(OS_WIN) | 1372 #if defined(OS_WIN) |
| 1369 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure; | 1373 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure; |
| 1370 #endif | 1374 #endif |
| 1371 complete_gpu_info_already_requested_ = true; | 1375 complete_gpu_info_already_requested_ = true; |
| 1372 // Some observers might be waiting. | 1376 // Some observers might be waiting. |
| 1373 NotifyGpuInfoUpdate(); | 1377 NotifyGpuInfoUpdate(); |
| 1374 } | 1378 } |
| 1375 | 1379 |
| 1376 } // namespace content | 1380 } // namespace content |
| OLD | NEW |