Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(367)

Side by Side Diff: content/gpu/gpu_info_collector_linux.cc

Issue 13730014: Remove PCI names lookup in gpu info collection in linux. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/gpu/gpu_info_collector.h" 5 #include "content/gpu/gpu_info_collector.h"
6 6
7 #include <X11/Xlib.h> 7 #include <X11/Xlib.h>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 // Fill the IDs and class fields. 123 // Fill the IDs and class fields.
124 (libpci_loader.pci_fill_info)(device, 33); 124 (libpci_loader.pci_fill_info)(device, 33);
125 // TODO(zmo): there might be other classes that qualify as display devices. 125 // TODO(zmo): there might be other classes that qualify as display devices.
126 if (device->device_class != 0x0300) // Device class is DISPLAY_VGA. 126 if (device->device_class != 0x0300) // Device class is DISPLAY_VGA.
127 continue; 127 continue;
128 128
129 content::GPUInfo::GPUDevice gpu; 129 content::GPUInfo::GPUDevice gpu;
130 gpu.vendor_id = device->vendor_id; 130 gpu.vendor_id = device->vendor_id;
131 gpu.device_id = device->device_id; 131 gpu.device_id = device->device_id;
132 132
133 const int buffer_size = 255;
134 scoped_array<char> buffer(new char[buffer_size]);
135 // The current implementation of pci_lookup_name returns the same pointer
136 // as the passed in upon success, and a different one (NULL or a pointer
137 // to an error message) upon failure.
138 if ((libpci_loader.pci_lookup_name)(access,
139 buffer.get(),
140 buffer_size,
141 1,
142 device->vendor_id) == buffer.get()) {
143 gpu.vendor_string = buffer.get();
144 }
145 if ((libpci_loader.pci_lookup_name)(access,
146 buffer.get(),
147 buffer_size,
148 2,
149 device->vendor_id,
150 device->device_id) == buffer.get()) {
151 std::string device_string = buffer.get();
152 size_t begin = device_string.find_first_of('[');
153 size_t end = device_string.find_last_of(']');
154 if (begin != std::string::npos && end != std::string::npos &&
155 begin < end) {
156 device_string = device_string.substr(begin + 1, end - begin - 1);
157 }
158 gpu.device_string = device_string;
159 }
160
161 if (!primary_gpu_identified) { 133 if (!primary_gpu_identified) {
162 primary_gpu_identified = true; 134 primary_gpu_identified = true;
163 gpu_info->gpu = gpu; 135 gpu_info->gpu = gpu;
164 } else { 136 } else {
165 // TODO(zmo): if there are multiple GPUs, we assume the non Intel 137 // TODO(zmo): if there are multiple GPUs, we assume the non Intel
166 // one is primary. Revisit this logic because we actually don't know 138 // one is primary. Revisit this logic because we actually don't know
167 // which GPU we are using at this point. 139 // which GPU we are using at this point.
168 if (gpu_info->gpu.vendor_id == kVendorIDIntel && 140 if (gpu_info->gpu.vendor_id == kVendorIDIntel &&
169 gpu.vendor_id != kVendorIDIntel) { 141 gpu.vendor_id != kVendorIDIntel) {
170 gpu_info->secondary_gpus.push_back(gpu_info->gpu); 142 gpu_info->secondary_gpus.push_back(gpu_info->gpu);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 gpu_info->driver_version = driver_version; 265 gpu_info->driver_version = driver_version;
294 return true; 266 return true;
295 } 267 }
296 268
297 void MergeGPUInfo(content::GPUInfo* basic_gpu_info, 269 void MergeGPUInfo(content::GPUInfo* basic_gpu_info,
298 const content::GPUInfo& context_gpu_info) { 270 const content::GPUInfo& context_gpu_info) {
299 MergeGPUInfoGL(basic_gpu_info, context_gpu_info); 271 MergeGPUInfoGL(basic_gpu_info, context_gpu_info);
300 } 272 }
301 273
302 } // namespace gpu_info_collector 274 } // namespace gpu_info_collector
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698