Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(357)

Side by Side Diff: gpu/config/gpu_info_collector.cc

Issue 1998723002: Move code in ui/gl/* from gfx:: to gl:: (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 10 matching lines...) Expand all
21 #include "gpu/config/gpu_switches.h" 21 #include "gpu/config/gpu_switches.h"
22 #include "ui/gl/gl_bindings.h" 22 #include "ui/gl/gl_bindings.h"
23 #include "ui/gl/gl_context.h" 23 #include "ui/gl/gl_context.h"
24 #include "ui/gl/gl_implementation.h" 24 #include "ui/gl/gl_implementation.h"
25 #include "ui/gl/gl_surface.h" 25 #include "ui/gl/gl_surface.h"
26 #include "ui/gl/gl_version_info.h" 26 #include "ui/gl/gl_version_info.h"
27 #include "ui/gl/init/gl_factory.h" 27 #include "ui/gl/init/gl_factory.h"
28 28
29 namespace { 29 namespace {
30 30
31 scoped_refptr<gfx::GLSurface> InitializeGLSurface() { 31 scoped_refptr<gl::GLSurface> InitializeGLSurface() {
32 scoped_refptr<gfx::GLSurface> surface( 32 scoped_refptr<gl::GLSurface> surface(
33 gl::init::CreateOffscreenGLSurface(gfx::Size())); 33 gl::init::CreateOffscreenGLSurface(gfx::Size()));
34 if (!surface.get()) { 34 if (!surface.get()) {
35 LOG(ERROR) << "gfx::GLContext::CreateOffscreenGLSurface failed"; 35 LOG(ERROR) << "gl::GLContext::CreateOffscreenGLSurface failed";
36 return NULL; 36 return NULL;
37 } 37 }
38 38
39 return surface; 39 return surface;
40 } 40 }
41 41
42 scoped_refptr<gfx::GLContext> InitializeGLContext(gfx::GLSurface* surface) { 42 scoped_refptr<gl::GLContext> InitializeGLContext(gl::GLSurface* surface) {
43 scoped_refptr<gfx::GLContext> context( 43 scoped_refptr<gl::GLContext> context(
44 gl::init::CreateGLContext(nullptr, surface, gfx::PreferIntegratedGpu)); 44 gl::init::CreateGLContext(nullptr, surface, gl::PreferIntegratedGpu));
45 if (!context.get()) { 45 if (!context.get()) {
46 LOG(ERROR) << "gl::init::CreateGLContext failed"; 46 LOG(ERROR) << "gl::init::CreateGLContext failed";
47 return NULL; 47 return NULL;
48 } 48 }
49 49
50 if (!context->MakeCurrent(surface)) { 50 if (!context->MakeCurrent(surface)) {
51 LOG(ERROR) << "gfx::GLContext::MakeCurrent() failed"; 51 LOG(ERROR) << "gl::GLContext::MakeCurrent() failed";
52 return NULL; 52 return NULL;
53 } 53 }
54 54
55 return context; 55 return context;
56 } 56 }
57 57
58 std::string GetGLString(unsigned int pname) { 58 std::string GetGLString(unsigned int pname) {
59 const char* gl_string = 59 const char* gl_string =
60 reinterpret_cast<const char*>(glGetString(pname)); 60 reinterpret_cast<const char*>(glGetString(pname));
61 if (gl_string) 61 if (gl_string)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 } 94 }
95 return -1; 95 return -1;
96 } 96 }
97 97
98 } // namespace anonymous 98 } // namespace anonymous
99 99
100 namespace gpu { 100 namespace gpu {
101 101
102 CollectInfoResult CollectGraphicsInfoGL(GPUInfo* gpu_info) { 102 CollectInfoResult CollectGraphicsInfoGL(GPUInfo* gpu_info) {
103 TRACE_EVENT0("startup", "gpu_info_collector::CollectGraphicsInfoGL"); 103 TRACE_EVENT0("startup", "gpu_info_collector::CollectGraphicsInfoGL");
104 DCHECK_NE(gfx::GetGLImplementation(), gfx::kGLImplementationNone); 104 DCHECK_NE(gl::GetGLImplementation(), gl::kGLImplementationNone);
105 105
106 scoped_refptr<gfx::GLSurface> surface(InitializeGLSurface()); 106 scoped_refptr<gl::GLSurface> surface(InitializeGLSurface());
107 if (!surface.get()) { 107 if (!surface.get()) {
108 LOG(ERROR) << "Could not create surface for info collection."; 108 LOG(ERROR) << "Could not create surface for info collection.";
109 return kCollectInfoFatalFailure; 109 return kCollectInfoFatalFailure;
110 } 110 }
111 111
112 scoped_refptr<gfx::GLContext> context(InitializeGLContext(surface.get())); 112 scoped_refptr<gl::GLContext> context(InitializeGLContext(surface.get()));
113 if (!context.get()) { 113 if (!context.get()) {
114 LOG(ERROR) << "Could not create context for info collection."; 114 LOG(ERROR) << "Could not create context for info collection.";
115 return kCollectInfoFatalFailure; 115 return kCollectInfoFatalFailure;
116 } 116 }
117 117
118 gpu_info->gl_renderer = GetGLString(GL_RENDERER); 118 gpu_info->gl_renderer = GetGLString(GL_RENDERER);
119 gpu_info->gl_vendor = GetGLString(GL_VENDOR); 119 gpu_info->gl_vendor = GetGLString(GL_VENDOR);
120 gpu_info->gl_version = GetGLString(GL_VERSION); 120 gpu_info->gl_version = GetGLString(GL_VERSION);
121 121
122 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 122 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
123 if (command_line->HasSwitch(switches::kGpuTestingGLVendor)) { 123 if (command_line->HasSwitch(switches::kGpuTestingGLVendor)) {
124 gpu_info->gl_vendor = 124 gpu_info->gl_vendor =
125 command_line->GetSwitchValueASCII(switches::kGpuTestingGLVendor); 125 command_line->GetSwitchValueASCII(switches::kGpuTestingGLVendor);
126 } 126 }
127 if (command_line->HasSwitch(switches::kGpuTestingGLRenderer)) { 127 if (command_line->HasSwitch(switches::kGpuTestingGLRenderer)) {
128 gpu_info->gl_renderer = 128 gpu_info->gl_renderer =
129 command_line->GetSwitchValueASCII(switches::kGpuTestingGLRenderer); 129 command_line->GetSwitchValueASCII(switches::kGpuTestingGLRenderer);
130 } 130 }
131 if (command_line->HasSwitch(switches::kGpuTestingGLVersion)) { 131 if (command_line->HasSwitch(switches::kGpuTestingGLVersion)) {
132 gpu_info->gl_version = 132 gpu_info->gl_version =
133 command_line->GetSwitchValueASCII(switches::kGpuTestingGLVersion); 133 command_line->GetSwitchValueASCII(switches::kGpuTestingGLVersion);
134 } 134 }
135 135
136 gpu_info->gl_extensions = gfx::GetGLExtensionsFromCurrentContext(); 136 gpu_info->gl_extensions = gl::GetGLExtensionsFromCurrentContext();
137 std::string glsl_version_string = GetGLString(GL_SHADING_LANGUAGE_VERSION); 137 std::string glsl_version_string = GetGLString(GL_SHADING_LANGUAGE_VERSION);
138 138
139 gfx::GLVersionInfo gl_info(gpu_info->gl_version.c_str(), 139 gl::GLVersionInfo gl_info(gpu_info->gl_version.c_str(),
140 gpu_info->gl_renderer.c_str(), 140 gpu_info->gl_renderer.c_str(),
141 gpu_info->gl_extensions.c_str()); 141 gpu_info->gl_extensions.c_str());
142 GLint max_samples = 0; 142 GLint max_samples = 0;
143 if (gl_info.IsAtLeastGL(3, 0) || gl_info.IsAtLeastGLES(3, 0) || 143 if (gl_info.IsAtLeastGL(3, 0) || gl_info.IsAtLeastGLES(3, 0) ||
144 gpu_info->gl_extensions.find("GL_ANGLE_framebuffer_multisample") != 144 gpu_info->gl_extensions.find("GL_ANGLE_framebuffer_multisample") !=
145 std::string::npos || 145 std::string::npos ||
146 gpu_info->gl_extensions.find("GL_APPLE_framebuffer_multisample") != 146 gpu_info->gl_extensions.find("GL_APPLE_framebuffer_multisample") !=
147 std::string::npos || 147 std::string::npos ||
148 gpu_info->gl_extensions.find("GL_EXT_framebuffer_multisample") != 148 gpu_info->gl_extensions.find("GL_EXT_framebuffer_multisample") !=
149 std::string::npos || 149 std::string::npos ||
150 gpu_info->gl_extensions.find("GL_EXT_multisampled_render_to_texture") != 150 gpu_info->gl_extensions.find("GL_EXT_multisampled_render_to_texture") !=
151 std::string::npos || 151 std::string::npos ||
152 gpu_info->gl_extensions.find("GL_NV_framebuffer_multisample") != 152 gpu_info->gl_extensions.find("GL_NV_framebuffer_multisample") !=
153 std::string::npos) { 153 std::string::npos) {
154 glGetIntegerv(GL_MAX_SAMPLES, &max_samples); 154 glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
155 } 155 }
156 gpu_info->max_msaa_samples = base::IntToString(max_samples); 156 gpu_info->max_msaa_samples = base::IntToString(max_samples);
157 UMA_HISTOGRAM_SPARSE_SLOWLY("GPU.MaxMSAASampleCount", max_samples); 157 UMA_HISTOGRAM_SPARSE_SLOWLY("GPU.MaxMSAASampleCount", max_samples);
158 158
159 gfx::GLWindowSystemBindingInfo window_system_binding_info; 159 gl::GLWindowSystemBindingInfo window_system_binding_info;
160 if (GetGLWindowSystemBindingInfo(&window_system_binding_info)) { 160 if (GetGLWindowSystemBindingInfo(&window_system_binding_info)) {
161 gpu_info->gl_ws_vendor = window_system_binding_info.vendor; 161 gpu_info->gl_ws_vendor = window_system_binding_info.vendor;
162 gpu_info->gl_ws_version = window_system_binding_info.version; 162 gpu_info->gl_ws_version = window_system_binding_info.version;
163 gpu_info->gl_ws_extensions = window_system_binding_info.extensions; 163 gpu_info->gl_ws_extensions = window_system_binding_info.extensions;
164 gpu_info->direct_rendering = window_system_binding_info.direct_rendering; 164 gpu_info->direct_rendering = window_system_binding_info.direct_rendering;
165 } 165 }
166 166
167 bool supports_robustness = 167 bool supports_robustness =
168 gpu_info->gl_extensions.find("GL_EXT_robustness") != std::string::npos || 168 gpu_info->gl_extensions.find("GL_EXT_robustness") != std::string::npos ||
169 gpu_info->gl_extensions.find("GL_KHR_robustness") != std::string::npos || 169 gpu_info->gl_extensions.find("GL_KHR_robustness") != std::string::npos ||
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 for (size_t ii = 0; ii < gpu_info->secondary_gpus.size(); ++ii) { 281 for (size_t ii = 0; ii < gpu_info->secondary_gpus.size(); ++ii) {
282 if (active_vendor_id == gpu_info->secondary_gpus[ii].vendor_id) { 282 if (active_vendor_id == gpu_info->secondary_gpus[ii].vendor_id) {
283 gpu_info->secondary_gpus[ii].active = true; 283 gpu_info->secondary_gpus[ii].active = true;
284 return; 284 return;
285 } 285 }
286 } 286 }
287 } 287 }
288 288
289 } // namespace gpu 289 } // namespace gpu
290 290
OLDNEW
« no previous file with comments | « gpu/command_buffer/tests/gl_unittests_android.cc ('k') | gpu/config/gpu_info_collector_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698