| 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 "gpu/config/gpu_info_collector.h" | 5 #include "gpu/config/gpu_info_collector.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
| 11 #include "base/mac/scoped_cftyperef.h" | 11 #include "base/mac/scoped_cftyperef.h" |
| 12 #include "base/mac/scoped_ioobject.h" | 12 #include "base/mac/scoped_ioobject.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/strings/string_piece.h" | 15 #include "base/strings/string_piece.h" |
| 16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 17 #include "base/strings/sys_string_conversions.h" | 17 #include "base/strings/sys_string_conversions.h" |
| 18 #include "base/trace_event/trace_event.h" | 18 #include "base/trace_event/trace_event.h" |
| 19 #include "ui/gl/gl_bindings.h" | 19 #include "ui/gl/gl_bindings.h" |
| 20 #include "ui/gl/gl_context.h" | 20 #include "ui/gl/gl_context.h" |
| 21 #include "ui/gl/gl_implementation.h" | 21 #include "ui/gl/gl_implementation.h" |
| 22 | 22 |
| 23 #import <Cocoa/Cocoa.h> | 23 #import <Cocoa/Cocoa.h> |
| 24 #import <Foundation/Foundation.h> | 24 #import <Foundation/Foundation.h> |
| 25 #import <IOKit/IOKitLib.h> | 25 #import <IOKit/IOKitLib.h> |
| 26 #include <stddef.h> |
| 27 #include <stdint.h> |
| 26 | 28 |
| 27 namespace gpu { | 29 namespace gpu { |
| 28 | 30 |
| 29 namespace { | 31 namespace { |
| 30 | 32 |
| 31 const UInt32 kVendorIDIntel = 0x8086; | 33 const UInt32 kVendorIDIntel = 0x8086; |
| 32 const UInt32 kVendorIDNVidia = 0x10de; | 34 const UInt32 kVendorIDNVidia = 0x10de; |
| 33 const UInt32 kVendorIDAMD = 0x1002; | 35 const UInt32 kVendorIDAMD = 0x1002; |
| 34 | 36 |
| 35 // Return 0 if we couldn't find the property. | 37 // Return 0 if we couldn't find the property. |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 | 170 |
| 169 TRACE_EVENT0("gpu", "gpu_info_collector::CollectGraphicsInfo"); | 171 TRACE_EVENT0("gpu", "gpu_info_collector::CollectGraphicsInfo"); |
| 170 | 172 |
| 171 gpu_info->can_lose_context = | 173 gpu_info->can_lose_context = |
| 172 (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2); | 174 (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2); |
| 173 CollectInfoResult result = CollectGraphicsInfoGL(gpu_info); | 175 CollectInfoResult result = CollectGraphicsInfoGL(gpu_info); |
| 174 gpu_info->context_info_state = result; | 176 gpu_info->context_info_state = result; |
| 175 return result; | 177 return result; |
| 176 } | 178 } |
| 177 | 179 |
| 178 CollectInfoResult CollectGpuID(uint32* vendor_id, uint32* device_id) { | 180 CollectInfoResult CollectGpuID(uint32_t* vendor_id, uint32_t* device_id) { |
| 179 DCHECK(vendor_id && device_id); | 181 DCHECK(vendor_id && device_id); |
| 180 | 182 |
| 181 GPUInfo::GPUDevice gpu = GetActiveGPU(); | 183 GPUInfo::GPUDevice gpu = GetActiveGPU(); |
| 182 *vendor_id = gpu.vendor_id; | 184 *vendor_id = gpu.vendor_id; |
| 183 *device_id = gpu.device_id; | 185 *device_id = gpu.device_id; |
| 184 | 186 |
| 185 if (*vendor_id != 0 && *device_id != 0) | 187 if (*vendor_id != 0 && *device_id != 0) |
| 186 return kCollectInfoSuccess; | 188 return kCollectInfoSuccess; |
| 187 return kCollectInfoNonFatalFailure; | 189 return kCollectInfoNonFatalFailure; |
| 188 } | 190 } |
| 189 | 191 |
| 190 CollectInfoResult CollectBasicGraphicsInfo(GPUInfo* gpu_info) { | 192 CollectInfoResult CollectBasicGraphicsInfo(GPUInfo* gpu_info) { |
| 191 DCHECK(gpu_info); | 193 DCHECK(gpu_info); |
| 192 | 194 |
| 193 int32 model_major = 0, model_minor = 0; | 195 int32_t model_major = 0, model_minor = 0; |
| 194 base::mac::ParseModelIdentifier(base::mac::GetModelIdentifier(), | 196 base::mac::ParseModelIdentifier(base::mac::GetModelIdentifier(), |
| 195 &gpu_info->machine_model_name, | 197 &gpu_info->machine_model_name, |
| 196 &model_major, &model_minor); | 198 &model_major, &model_minor); |
| 197 gpu_info->machine_model_version = | 199 gpu_info->machine_model_version = |
| 198 base::IntToString(model_major) + "." + base::IntToString(model_minor); | 200 base::IntToString(model_major) + "." + base::IntToString(model_minor); |
| 199 | 201 |
| 200 CollectInfoResult result = CollectPCIVideoCardInfo(gpu_info); | 202 CollectInfoResult result = CollectPCIVideoCardInfo(gpu_info); |
| 201 gpu_info->basic_info_state = result; | 203 gpu_info->basic_info_state = result; |
| 202 return result; | 204 return result; |
| 203 } | 205 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 215 gpu_info->driver_version = gpu_info->gl_version.substr(pos + 1); | 217 gpu_info->driver_version = gpu_info->gl_version.substr(pos + 1); |
| 216 return kCollectInfoSuccess; | 218 return kCollectInfoSuccess; |
| 217 } | 219 } |
| 218 | 220 |
| 219 void MergeGPUInfo(GPUInfo* basic_gpu_info, | 221 void MergeGPUInfo(GPUInfo* basic_gpu_info, |
| 220 const GPUInfo& context_gpu_info) { | 222 const GPUInfo& context_gpu_info) { |
| 221 MergeGPUInfoGL(basic_gpu_info, context_gpu_info); | 223 MergeGPUInfoGL(basic_gpu_info, context_gpu_info); |
| 222 } | 224 } |
| 223 | 225 |
| 224 } // namespace gpu | 226 } // namespace gpu |
| OLD | NEW |