| 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 "content/gpu/gpu_info_collector.h" | 5 #include "content/gpu/gpu_info_collector.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 } | 151 } |
| 152 break; | 152 break; |
| 153 } | 153 } |
| 154 return (gpu_info->gpu.vendor_id && gpu_info->gpu.device_id); | 154 return (gpu_info->gpu.vendor_id && gpu_info->gpu.device_id); |
| 155 } | 155 } |
| 156 | 156 |
| 157 } // namespace anonymous | 157 } // namespace anonymous |
| 158 | 158 |
| 159 namespace gpu_info_collector { | 159 namespace gpu_info_collector { |
| 160 | 160 |
| 161 bool CollectContextGraphicsInfo(content::GPUInfo* gpu_info) { | 161 bool CollectGraphicsInfo(content::GPUInfo* gpu_info) { |
| 162 DCHECK(gpu_info); | 162 DCHECK(gpu_info); |
| 163 *gpu_info = content::GPUInfo(); |
| 163 | 164 |
| 164 TRACE_EVENT0("gpu", "gpu_info_collector::CollectGraphicsInfo"); | 165 TRACE_EVENT0("gpu", "gpu_info_collector::CollectGraphicsInfo"); |
| 165 | 166 |
| 166 gpu_info->can_lose_context = | 167 gpu_info->can_lose_context = |
| 167 (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2); | 168 (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2); |
| 168 gpu_info->finalized = true; | 169 gpu_info->finalized = true; |
| 169 return CollectGraphicsInfoGL(gpu_info); | 170 return CollectGraphicsInfoGL(gpu_info); |
| 170 } | 171 } |
| 171 | 172 |
| 172 bool CollectBasicGraphicsInfo(content::GPUInfo* gpu_info) { | 173 bool CollectPreliminaryGraphicsInfo(content::GPUInfo* gpu_info) { |
| 173 DCHECK(gpu_info); | 174 DCHECK(gpu_info); |
| 174 | 175 |
| 175 std::string model_name; | 176 std::string model_name; |
| 176 int32 model_major = 0, model_minor = 0; | 177 int32 model_major = 0, model_minor = 0; |
| 177 base::mac::ParseModelIdentifier(base::mac::GetModelIdentifier(), | 178 base::mac::ParseModelIdentifier(base::mac::GetModelIdentifier(), |
| 178 &model_name, &model_major, &model_minor); | 179 &model_name, &model_major, &model_minor); |
| 179 ReplaceChars(model_name, " ", "_", &gpu_info->machine_model); | 180 ReplaceChars(model_name, " ", "_", &gpu_info->machine_model); |
| 180 gpu_info->machine_model += " " + base::IntToString(model_major) + | 181 gpu_info->machine_model += " " + base::IntToString(model_major) + |
| 181 "." + base::IntToString(model_minor); | 182 "." + base::IntToString(model_minor); |
| 182 | 183 |
| 183 return CollectPCIVideoCardInfo(gpu_info); | 184 return CollectPCIVideoCardInfo(gpu_info); |
| 184 } | 185 } |
| 185 | 186 |
| 187 bool CollectVideoCardInfo(content::GPUInfo* gpu_info) { |
| 188 return CollectPreliminaryGraphicsInfo(gpu_info); |
| 189 } |
| 190 |
| 186 bool CollectDriverInfoGL(content::GPUInfo* gpu_info) { | 191 bool CollectDriverInfoGL(content::GPUInfo* gpu_info) { |
| 187 DCHECK(gpu_info); | 192 DCHECK(gpu_info); |
| 188 | 193 |
| 189 // Extract the OpenGL driver version string from the GL_VERSION string. | 194 // Extract the OpenGL driver version string from the GL_VERSION string. |
| 190 // Mac OpenGL drivers have the driver version | 195 // Mac OpenGL drivers have the driver version |
| 191 // at the end of the gl version string preceded by a dash. | 196 // at the end of the gl version string preceded by a dash. |
| 192 // Use some jiggery-pokery to turn that utf8 string into a std::wstring. | 197 // Use some jiggery-pokery to turn that utf8 string into a std::wstring. |
| 193 std::string gl_version_string = gpu_info->gl_version_string; | 198 std::string gl_version_string = gpu_info->gl_version_string; |
| 194 size_t pos = gl_version_string.find_last_of('-'); | 199 size_t pos = gl_version_string.find_last_of('-'); |
| 195 if (pos == std::string::npos) | 200 if (pos == std::string::npos) |
| 196 return false; | 201 return false; |
| 197 gpu_info->driver_version = gl_version_string.substr(pos + 1); | 202 gpu_info->driver_version = gl_version_string.substr(pos + 1); |
| 198 return true; | 203 return true; |
| 199 } | 204 } |
| 200 | 205 |
| 201 void MergeGPUInfo(content::GPUInfo* basic_gpu_info, | |
| 202 const content::GPUInfo& context_gpu_info) { | |
| 203 MergeGPUInfoGL(basic_gpu_info, context_gpu_info); | |
| 204 } | |
| 205 | |
| 206 } // namespace gpu_info_collector | 206 } // namespace gpu_info_collector |
| OLD | NEW |