| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/gpu/gpu_info_collector.h" | 5 #include "chrome/gpu/gpu_info_collector.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <d3d9.h> | 8 #include <d3d9.h> |
| 9 | 9 |
| 10 #include "app/gfx/gl/gl_context_egl.h" | 10 #include "app/gfx/gl/gl_context_egl.h" |
| 11 #include "app/gfx/gl/gl_implementation.h" | 11 #include "app/gfx/gl/gl_implementation.h" |
| 12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
| 13 #include "base/scoped_native_library.h" | 13 #include "base/scoped_native_library.h" |
| 14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
| 15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 16 | 16 |
| 17 // ANGLE seems to require that main.h be included before any other ANGLE header. | 17 // ANGLE seems to require that main.h be included before any other ANGLE header. |
| 18 #include "libEGL/main.h" | 18 #include "libEGL/main.h" |
| 19 #include "libEGL/Display.h" | 19 #include "libEGL/Display.h" |
| 20 | 20 |
| 21 namespace gpu_info_collector { | 21 namespace gpu_info_collector { |
| 22 | 22 |
| 23 bool CollectGraphicsInfo(GPUInfo* gpu_info) { | 23 bool CollectGraphicsInfo(GPUInfo* gpu_info) { |
| 24 DCHECK(gpu_info); | 24 DCHECK(gpu_info); |
| 25 | 25 |
| 26 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { | 26 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { |
| 27 gpu_info->SetLevel(GPUInfo::kComplete); | 27 gpu_info->SetProgress(GPUInfo::kComplete); |
| 28 return CollectGraphicsInfoGL(gpu_info); | 28 return CollectGraphicsInfoGL(gpu_info); |
| 29 } | 29 } |
| 30 | 30 |
| 31 // TODO(zmo): the following code only works if running on top of ANGLE. | 31 // TODO(zmo): the following code only works if running on top of ANGLE. |
| 32 // Need to handle the case when running on top of real EGL/GLES2 drivers. | 32 // Need to handle the case when running on top of real EGL/GLES2 drivers. |
| 33 | 33 |
| 34 egl::Display* display = static_cast<egl::Display*>( | 34 egl::Display* display = static_cast<egl::Display*>( |
| 35 gfx::BaseEGLContext::GetDisplay()); | 35 gfx::BaseEGLContext::GetDisplay()); |
| 36 if (!display) | 36 if (!display) |
| 37 return false; | 37 return false; |
| 38 | 38 |
| 39 IDirect3DDevice9* device = display->getDevice(); | 39 IDirect3DDevice9* device = display->getDevice(); |
| 40 if (!device) | 40 if (!device) |
| 41 return false; | 41 return false; |
| 42 | 42 |
| 43 IDirect3D9* d3d = NULL; | 43 IDirect3D9* d3d = NULL; |
| 44 if (FAILED(device->GetDirect3D(&d3d))) | 44 if (FAILED(device->GetDirect3D(&d3d))) |
| 45 return false; | 45 return false; |
| 46 | 46 |
| 47 if (!CollectGraphicsInfoD3D(d3d, gpu_info)) | 47 if (!CollectGraphicsInfoD3D(d3d, gpu_info)) |
| 48 return false; | 48 return false; |
| 49 | 49 |
| 50 // DirectX diagnostics are collected asynchronously because it takes a | 50 // DirectX diagnostics are collected asynchronously because it takes a |
| 51 // couple of seconds. Do not mark as complete until that is done. | 51 // couple of seconds. Do not mark as complete until that is done. |
| 52 gpu_info->SetLevel(GPUInfo::kPartial); | 52 gpu_info->SetProgress(GPUInfo::kPartial); |
| 53 return true; | 53 return true; |
| 54 } | 54 } |
| 55 | 55 |
| 56 bool CollectGraphicsInfoD3D(IDirect3D9* d3d, GPUInfo* gpu_info) { | 56 bool CollectGraphicsInfoD3D(IDirect3D9* d3d, GPUInfo* gpu_info) { |
| 57 DCHECK(d3d); | 57 DCHECK(d3d); |
| 58 DCHECK(gpu_info); | 58 DCHECK(gpu_info); |
| 59 | 59 |
| 60 bool succeed = true; | 60 bool succeed = true; |
| 61 | 61 |
| 62 // Get device/driver information | 62 // Get device/driver information |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 141 |
| 142 size_t pos = gl_version_string.find_last_not_of("0123456789."); | 142 size_t pos = gl_version_string.find_last_not_of("0123456789."); |
| 143 if (pos != std::string::npos && pos < gl_version_string.length() - 1) { | 143 if (pos != std::string::npos && pos < gl_version_string.length() - 1) { |
| 144 gpu_info->SetDriverInfo("", gl_version_string.substr(pos + 1)); | 144 gpu_info->SetDriverInfo("", gl_version_string.substr(pos + 1)); |
| 145 return true; | 145 return true; |
| 146 } | 146 } |
| 147 return false; | 147 return false; |
| 148 } | 148 } |
| 149 | 149 |
| 150 } // namespace gpu_info_collector | 150 } // namespace gpu_info_collector |
| OLD | NEW |