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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 scoped_refptr<gfx::GLSurface> surface(InitializeGLSurface()); | 87 scoped_refptr<gfx::GLSurface> surface(InitializeGLSurface()); |
88 if (!surface.get()) | 88 if (!surface.get()) |
89 return false; | 89 return false; |
90 | 90 |
91 scoped_refptr<gfx::GLContext> context(InitializeGLContext(surface.get())); | 91 scoped_refptr<gfx::GLContext> context(InitializeGLContext(surface.get())); |
92 if (!context.get()) | 92 if (!context.get()) |
93 return false; | 93 return false; |
94 | 94 |
95 gpu_info->gl_renderer = GetGLString(GL_RENDERER); | 95 gpu_info->gl_renderer = GetGLString(GL_RENDERER); |
96 gpu_info->gl_vendor = GetGLString(GL_VENDOR); | 96 gpu_info->gl_vendor = GetGLString(GL_VENDOR); |
97 gpu_info->gl_extensions = GetGLString(GL_EXTENSIONS); | 97 gpu_info->gl_version_string =GetGLString(GL_VERSION); |
98 gpu_info->gl_version_string = GetGLString(GL_VERSION); | 98 gpu_info->gl_extensions =GetGLString(GL_EXTENSIONS); |
99 std::string glsl_version_string = GetGLString(GL_SHADING_LANGUAGE_VERSION); | 99 |
| 100 bool validGLVersionInfo = CollectGLVersionInfo(gpu_info); |
| 101 bool validVideoCardInfo = CollectVideoCardInfo(gpu_info); |
| 102 bool validDriverInfo = CollectDriverInfoGL(gpu_info); |
| 103 |
100 // TODO(kbr): remove once the destruction of a current context automatically | 104 // TODO(kbr): remove once the destruction of a current context automatically |
101 // clears the current context. | 105 // clears the current context. |
102 context->ReleaseCurrent(surface.get()); | 106 context->ReleaseCurrent(surface.get()); |
103 | 107 |
104 gpu_info->gl_version = GetVersionFromString(gpu_info->gl_version_string); | 108 return (validGLVersionInfo && validVideoCardInfo && validDriverInfo); |
| 109 } |
| 110 |
| 111 bool CollectGLVersionInfo(content::GPUInfo* gpu_info) { |
| 112 std::string gl_version_string = gpu_info->gl_version_string; |
| 113 std::string glsl_version_string = |
| 114 GetGLString(GL_SHADING_LANGUAGE_VERSION); |
| 115 |
| 116 gpu_info->gl_version = GetVersionFromString(gl_version_string); |
| 117 |
105 std::string glsl_version = GetVersionFromString(glsl_version_string); | 118 std::string glsl_version = GetVersionFromString(glsl_version_string); |
106 gpu_info->pixel_shader_version = glsl_version; | 119 gpu_info->pixel_shader_version = glsl_version; |
107 gpu_info->vertex_shader_version = glsl_version; | 120 gpu_info->vertex_shader_version = glsl_version; |
108 | 121 |
109 return CollectDriverInfoGL(gpu_info); | 122 return true; |
110 } | |
111 | |
112 void MergeGPUInfoGL(content::GPUInfo* basic_gpu_info, | |
113 const content::GPUInfo& context_gpu_info) { | |
114 DCHECK(basic_gpu_info); | |
115 basic_gpu_info->gl_renderer = context_gpu_info.gl_renderer; | |
116 basic_gpu_info->gl_vendor = context_gpu_info.gl_vendor; | |
117 basic_gpu_info->gl_version_string = context_gpu_info.gl_version_string; | |
118 basic_gpu_info->gl_extensions = context_gpu_info.gl_extensions; | |
119 basic_gpu_info->gl_version = context_gpu_info.gl_version; | |
120 basic_gpu_info->pixel_shader_version = | |
121 context_gpu_info.pixel_shader_version; | |
122 basic_gpu_info->vertex_shader_version = | |
123 context_gpu_info.vertex_shader_version; | |
124 | |
125 if (!context_gpu_info.driver_vendor.empty()) | |
126 basic_gpu_info->driver_vendor = context_gpu_info.driver_vendor; | |
127 if (!context_gpu_info.driver_version.empty()) | |
128 basic_gpu_info->driver_version = context_gpu_info.driver_version; | |
129 | |
130 basic_gpu_info->can_lose_context = context_gpu_info.can_lose_context; | |
131 basic_gpu_info->sandboxed = context_gpu_info.sandboxed; | |
132 basic_gpu_info->gpu_accessible = context_gpu_info.gpu_accessible; | |
133 basic_gpu_info->finalized = context_gpu_info.finalized; | |
134 basic_gpu_info->initialization_time = context_gpu_info.initialization_time; | |
135 } | 123 } |
136 | 124 |
137 } // namespace gpu_info_collector | 125 } // namespace gpu_info_collector |
138 | 126 |
OLD | NEW |