OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <dlfcn.h> | 7 #include <dlfcn.h> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/string_piece.h" | 14 #include "base/string_piece.h" |
15 #include "base/string_split.h" | 15 #include "base/string_split.h" |
16 #include "base/string_tokenizer.h" | 16 #include "base/string_tokenizer.h" |
17 #include "base/string_util.h" | 17 #include "base/string_util.h" |
18 #include "ui/gfx/gl/gl_bindings.h" | 18 #include "ui/gfx/gl/gl_bindings.h" |
19 #include "ui/gfx/gl/gl_context.h" | 19 #include "ui/gfx/gl/gl_context.h" |
20 #include "ui/gfx/gl/gl_implementation.h" | 20 #include "ui/gfx/gl/gl_implementation.h" |
| 21 #include "ui/gfx/gl/gl_surface.h" |
21 #include "ui/gfx/gl/gl_switches.h" | 22 #include "ui/gfx/gl/gl_switches.h" |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
25 // PciDevice and PciAccess are defined to access libpci functions. Their | 26 // PciDevice and PciAccess are defined to access libpci functions. Their |
26 // members match the corresponding structures defined by libpci in size up to | 27 // members match the corresponding structures defined by libpci in size up to |
27 // fields we may access. For those members we don't use, their names are | 28 // fields we may access. For those members we don't use, their names are |
28 // defined as "fieldX", etc., or, left out if they are declared after the | 29 // defined as "fieldX", etc., or, left out if they are declared after the |
29 // members we care about in libpci. | 30 // members we care about in libpci. |
30 | 31 |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2); | 205 (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2); |
205 } | 206 } |
206 | 207 |
207 gpu_info->finalized = true; | 208 gpu_info->finalized = true; |
208 return CollectGraphicsInfoGL(gpu_info); | 209 return CollectGraphicsInfoGL(gpu_info); |
209 } | 210 } |
210 | 211 |
211 bool CollectPreliminaryGraphicsInfo(GPUInfo* gpu_info) { | 212 bool CollectPreliminaryGraphicsInfo(GPUInfo* gpu_info) { |
212 DCHECK(gpu_info); | 213 DCHECK(gpu_info); |
213 | 214 |
| 215 if (!gfx::GLSurface::InitializeOneOff()) { |
| 216 LOG(ERROR) << "gfx::GLContext::InitializeOneOff() failed"; |
| 217 return false; |
| 218 } |
| 219 |
214 bool rt = true; | 220 bool rt = true; |
215 if (!CollectVideoCardInfo(gpu_info)) | 221 if (!CollectVideoCardInfo(gpu_info)) |
216 rt = false; | 222 rt = false; |
217 | 223 |
218 if (gpu_info->vendor_id == 0x1002) { // ATI | 224 if (gpu_info->vendor_id == 0x1002) { // ATI |
219 std::string ati_driver_version = CollectDriverVersionATI(); | 225 std::string ati_driver_version = CollectDriverVersionATI(); |
220 if (ati_driver_version != "") { | 226 if (ati_driver_version != "") { |
221 gpu_info->driver_vendor = "ATI / AMD"; | 227 gpu_info->driver_vendor = "ATI / AMD"; |
222 gpu_info->driver_version = ati_driver_version; | 228 gpu_info->driver_version = ati_driver_version; |
223 } | 229 } |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 return false; | 351 return false; |
346 if (pos != std::string::npos) | 352 if (pos != std::string::npos) |
347 driver_version = driver_version.substr(0, pos); | 353 driver_version = driver_version.substr(0, pos); |
348 | 354 |
349 gpu_info->driver_vendor = pieces[1]; | 355 gpu_info->driver_vendor = pieces[1]; |
350 gpu_info->driver_version = driver_version; | 356 gpu_info->driver_version = driver_version; |
351 return true; | 357 return true; |
352 } | 358 } |
353 | 359 |
354 } // namespace gpu_info_collector | 360 } // namespace gpu_info_collector |
OLD | NEW |