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 "gpu/config/gpu_util.h" | 5 #include "gpu/config/gpu_util.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 28 matching lines...) Expand all Loading... | |
39 for (const base::StringPiece& piece : | 39 for (const base::StringPiece& piece : |
40 base::SplitStringPiece(str, ",", base::TRIM_WHITESPACE, | 40 base::SplitStringPiece(str, ",", base::TRIM_WHITESPACE, |
41 base::SPLIT_WANT_ALL)) { | 41 base::SPLIT_WANT_ALL)) { |
42 int number = 0; | 42 int number = 0; |
43 bool succeed = base::StringToInt(piece, &number); | 43 bool succeed = base::StringToInt(piece, &number); |
44 DCHECK(succeed); | 44 DCHECK(succeed); |
45 list->insert(number); | 45 list->insert(number); |
46 } | 46 } |
47 } | 47 } |
48 | 48 |
49 // |str| is in the format of "0x040a;0x10de;...;hex32_N". | |
50 void StringToIds(const std::string& str, std::vector<uint32_t>* list) { | |
51 DCHECK(list); | |
52 for (const base::StringPiece& piece : base::SplitStringPiece( | |
53 str, ";", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { | |
54 uint32_t id = 0; | |
55 bool succeed = base::HexStringToUInt(piece, &id); | |
56 DCHECK(succeed); | |
57 list->push_back(id); | |
58 } | |
59 } | |
60 | |
49 } // namespace anonymous | 61 } // namespace anonymous |
50 | 62 |
51 void MergeFeatureSets(std::set<int>* dst, const std::set<int>& src) { | 63 void MergeFeatureSets(std::set<int>* dst, const std::set<int>& src) { |
52 DCHECK(dst); | 64 DCHECK(dst); |
53 if (src.empty()) | 65 if (src.empty()) |
54 return; | 66 return; |
55 dst->insert(src.begin(), src.end()); | 67 dst->insert(src.begin(), src.end()); |
56 } | 68 } |
57 | 69 |
58 void ApplyGpuDriverBugWorkarounds(const GPUInfo& gpu_info, | 70 void ApplyGpuDriverBugWorkarounds(const GPUInfo& gpu_info, |
(...skipping 30 matching lines...) Expand all Loading... | |
89 command_line->AppendSwitchASCII(switches::kDisableGLExtensions, | 101 command_line->AppendSwitchASCII(switches::kDisableGLExtensions, |
90 base::JoinString(v, " ")); | 102 base::JoinString(v, " ")); |
91 } | 103 } |
92 } | 104 } |
93 | 105 |
94 void StringToFeatureSet( | 106 void StringToFeatureSet( |
95 const std::string& str, std::set<int>* feature_set) { | 107 const std::string& str, std::set<int>* feature_set) { |
96 StringToIntSet(str, feature_set); | 108 StringToIntSet(str, feature_set); |
97 } | 109 } |
98 | 110 |
111 void ParseSecondaryGpuDevicesFromCommandLine( | |
112 const base::CommandLine& command_line, | |
113 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.
| |
114 GPUInfo* gpu_info) { | |
115 const char* secondary_vendor_ids_key = switches::kGpuSecondaryVendorIDs; | |
116 const char* secondary_device_ids_key = switches::kGpuSecondaryDeviceIDs; | |
117 | |
118 if (use_testing_switches) { | |
119 secondary_vendor_ids_key = switches::kGpuTestingSecondaryVendorIDs; | |
120 secondary_device_ids_key = switches::kGpuTestingSecondaryDeviceIDs; | |
121 } | |
122 | |
123 if (!command_line.HasSwitch(secondary_vendor_ids_key) || | |
124 !command_line.HasSwitch(secondary_device_ids_key)) { | |
125 return; | |
126 } | |
127 | |
128 std::vector<uint32_t> vendor_ids; | |
129 std::vector<uint32_t> device_ids; | |
130 StringToIds(command_line.GetSwitchValueASCII(secondary_vendor_ids_key), | |
131 &vendor_ids); | |
132 StringToIds(command_line.GetSwitchValueASCII(secondary_device_ids_key), | |
133 &device_ids); | |
134 | |
135 DCHECK(vendor_ids.size() == device_ids.size()); | |
136 gpu_info->secondary_gpus.clear(); | |
137 for (size_t i = 0; i < vendor_ids.size() && i < device_ids.size(); ++i) { | |
138 gpu::GPUInfo::GPUDevice secondary_device; | |
139 secondary_device.active = false; | |
140 secondary_device.vendor_id = vendor_ids[i]; | |
141 secondary_device.device_id = device_ids[i]; | |
142 gpu_info->secondary_gpus.push_back(secondary_device); | |
143 } | |
144 } | |
145 | |
99 } // namespace gpu | 146 } // namespace gpu |
OLD | NEW |