Chromium Code Reviews| Index: gpu/config/gpu_util.cc |
| diff --git a/gpu/config/gpu_util.cc b/gpu/config/gpu_util.cc |
| index 525d3087b4f979f77191bebfa8611f254c7f340d..f6329cb0a2c9b98d067f524a596836f90cf8efbb 100644 |
| --- a/gpu/config/gpu_util.cc |
| +++ b/gpu/config/gpu_util.cc |
| @@ -46,6 +46,18 @@ void StringToIntSet(const std::string& str, std::set<int>* list) { |
| } |
| } |
| +// |str| is in the format of "0x040a,0x10de,...,hex32_N". |
|
Zhenyao Mo
2016/04/19 21:05:27
not ',', but ';'
Julien Isorce Samsung
2016/04/20 17:19:21
Thx
|
| +void StringToIds(const std::string& str, std::vector<uint32_t>* list) { |
| + DCHECK(list); |
| + for (const base::StringPiece& piece : base::SplitStringPiece( |
| + str, ";", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { |
| + uint32_t id = 0; |
| + bool succeed = base::HexStringToUInt(piece, &id); |
| + DCHECK(succeed); |
| + list->push_back(id); |
| + } |
| +} |
| + |
| } // namespace anonymous |
| void MergeFeatureSets(std::set<int>* dst, const std::set<int>& src) { |
| @@ -96,4 +108,32 @@ void StringToFeatureSet( |
| StringToIntSet(str, feature_set); |
| } |
| +void ParseSecondaryGpuDevicesFromCommandLine( |
| + const base::CommandLine& command_line, |
| + const std::string& secondary_vendor_ids_key, |
| + const std::string& secondary_device_ids_key, |
| + GPUInfo* gpu_info) { |
| + if (!command_line.HasSwitch(secondary_vendor_ids_key) || |
| + !command_line.HasSwitch(secondary_device_ids_key)) { |
| + return; |
| + } |
| + |
| + std::vector<uint32_t> vendor_ids; |
| + std::vector<uint32_t> device_ids; |
| + StringToIds(command_line.GetSwitchValueASCII(secondary_vendor_ids_key), |
| + &vendor_ids); |
| + StringToIds(command_line.GetSwitchValueASCII(secondary_device_ids_key), |
| + &device_ids); |
| + |
| + DCHECK(vendor_ids.size() == device_ids.size()); |
| + gpu_info->secondary_gpus.clear(); |
| + for (size_t i = 0; i < vendor_ids.size() && i < device_ids.size(); ++i) { |
| + gpu::GPUInfo::GPUDevice secondary_device; |
| + secondary_device.active = false; |
| + secondary_device.vendor_id = vendor_ids[i]; |
| + secondary_device.device_id = device_ids[i]; |
| + gpu_info->secondary_gpus.push_back(secondary_device); |
| + } |
| +} |
| + |
| } // namespace gpu |