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 CollectGraphicsInfo(content::GPUInfo* gpu_info) { | 161 bool CollectContextGraphicsInfo(content::GPUInfo* gpu_info) { |
162 DCHECK(gpu_info); | 162 DCHECK(gpu_info); |
163 *gpu_info = content::GPUInfo(); | |
164 | 163 |
165 TRACE_EVENT0("gpu", "gpu_info_collector::CollectGraphicsInfo"); | 164 TRACE_EVENT0("gpu", "gpu_info_collector::CollectGraphicsInfo"); |
166 | 165 |
167 gpu_info->can_lose_context = | 166 gpu_info->can_lose_context = |
168 (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2); | 167 (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2); |
169 gpu_info->finalized = true; | 168 gpu_info->finalized = true; |
170 return CollectGraphicsInfoGL(gpu_info); | 169 return CollectGraphicsInfoGL(gpu_info); |
171 } | 170 } |
172 | 171 |
173 bool CollectPreliminaryGraphicsInfo(content::GPUInfo* gpu_info) { | 172 bool CollectBasicGraphicsInfo(content::GPUInfo* gpu_info) { |
174 DCHECK(gpu_info); | 173 DCHECK(gpu_info); |
175 | 174 |
176 std::string model_name; | 175 std::string model_name; |
177 int32 model_major = 0, model_minor = 0; | 176 int32 model_major = 0, model_minor = 0; |
178 base::mac::ParseModelIdentifier(base::mac::GetModelIdentifier(), | 177 base::mac::ParseModelIdentifier(base::mac::GetModelIdentifier(), |
179 &model_name, &model_major, &model_minor); | 178 &model_name, &model_major, &model_minor); |
180 ReplaceChars(model_name, " ", "_", &gpu_info->machine_model); | 179 ReplaceChars(model_name, " ", "_", &gpu_info->machine_model); |
181 gpu_info->machine_model += " " + base::IntToString(model_major) + | 180 gpu_info->machine_model += " " + base::IntToString(model_major) + |
182 "." + base::IntToString(model_minor); | 181 "." + base::IntToString(model_minor); |
183 | 182 |
184 return CollectPCIVideoCardInfo(gpu_info); | 183 return CollectPCIVideoCardInfo(gpu_info); |
185 } | 184 } |
186 | 185 |
187 bool CollectVideoCardInfo(content::GPUInfo* gpu_info) { | |
188 return CollectPreliminaryGraphicsInfo(gpu_info); | |
189 } | |
190 | |
191 bool CollectDriverInfoGL(content::GPUInfo* gpu_info) { | 186 bool CollectDriverInfoGL(content::GPUInfo* gpu_info) { |
192 DCHECK(gpu_info); | 187 DCHECK(gpu_info); |
193 | 188 |
194 // Extract the OpenGL driver version string from the GL_VERSION string. | 189 // Extract the OpenGL driver version string from the GL_VERSION string. |
195 // Mac OpenGL drivers have the driver version | 190 // Mac OpenGL drivers have the driver version |
196 // at the end of the gl version string preceded by a dash. | 191 // at the end of the gl version string preceded by a dash. |
197 // Use some jiggery-pokery to turn that utf8 string into a std::wstring. | 192 // Use some jiggery-pokery to turn that utf8 string into a std::wstring. |
198 std::string gl_version_string = gpu_info->gl_version_string; | 193 std::string gl_version_string = gpu_info->gl_version_string; |
199 size_t pos = gl_version_string.find_last_of('-'); | 194 size_t pos = gl_version_string.find_last_of('-'); |
200 if (pos == std::string::npos) | 195 if (pos == std::string::npos) |
201 return false; | 196 return false; |
202 gpu_info->driver_version = gl_version_string.substr(pos + 1); | 197 gpu_info->driver_version = gl_version_string.substr(pos + 1); |
203 return true; | 198 return true; |
204 } | 199 } |
205 | 200 |
| 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 |