Index: gpu/config/gpu_util.cc |
diff --git a/gpu/config/gpu_util.cc b/gpu/config/gpu_util.cc |
index 525d3087b4f979f77191bebfa8611f254c7f340d..df093d335a2a506afd34da5a2bb85c96547f039f 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". |
+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,39 @@ void StringToFeatureSet( |
StringToIntSet(str, feature_set); |
} |
+void ParseSecondaryGpuDevicesFromCommandLine( |
+ const base::CommandLine& command_line, |
+ bool use_testing_switches, |
Zhenyao Mo
2016/04/21 17:03:37
I don't think you need this bool. If testing swit
Julien Isorce Samsung
2016/04/21 23:27:08
Done.
|
+ GPUInfo* gpu_info) { |
+ const char* secondary_vendor_ids_key = switches::kGpuSecondaryVendorIDs; |
+ const char* secondary_device_ids_key = switches::kGpuSecondaryDeviceIDs; |
+ |
+ if (use_testing_switches) { |
+ secondary_vendor_ids_key = switches::kGpuTestingSecondaryVendorIDs; |
+ secondary_device_ids_key = switches::kGpuTestingSecondaryDeviceIDs; |
+ } |
+ |
+ 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 |