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

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

Issue 1481523003: Check gl version before querying GL_MAX_SAMPLES (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/metrics/sparse_histogram.h" 12 #include "base/metrics/sparse_histogram.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/string_piece.h" 14 #include "base/strings/string_piece.h"
15 #include "base/strings/string_split.h" 15 #include "base/strings/string_split.h"
16 #include "base/trace_event/trace_event.h" 16 #include "base/trace_event/trace_event.h"
17 #include "ui/gl/gl_bindings.h" 17 #include "ui/gl/gl_bindings.h"
18 #include "ui/gl/gl_context.h" 18 #include "ui/gl/gl_context.h"
19 #include "ui/gl/gl_implementation.h" 19 #include "ui/gl/gl_implementation.h"
20 #include "ui/gl/gl_surface.h" 20 #include "ui/gl/gl_surface.h"
21 #include "ui/gl/gl_version_info.h"
21 22
22 namespace { 23 namespace {
23 24
24 scoped_refptr<gfx::GLSurface> InitializeGLSurface() { 25 scoped_refptr<gfx::GLSurface> InitializeGLSurface() {
25 scoped_refptr<gfx::GLSurface> surface( 26 scoped_refptr<gfx::GLSurface> surface(
26 gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size())); 27 gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size()));
27 if (!surface.get()) { 28 if (!surface.get()) {
28 LOG(ERROR) << "gfx::GLContext::CreateOffscreenGLSurface failed"; 29 LOG(ERROR) << "gfx::GLContext::CreateOffscreenGLSurface failed";
29 return NULL; 30 return NULL;
30 } 31 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 if (!context.get()) { 96 if (!context.get()) {
96 LOG(ERROR) << "Could not create context for info collection."; 97 LOG(ERROR) << "Could not create context for info collection.";
97 return kCollectInfoFatalFailure; 98 return kCollectInfoFatalFailure;
98 } 99 }
99 100
100 gpu_info->gl_renderer = GetGLString(GL_RENDERER); 101 gpu_info->gl_renderer = GetGLString(GL_RENDERER);
101 gpu_info->gl_vendor = GetGLString(GL_VENDOR); 102 gpu_info->gl_vendor = GetGLString(GL_VENDOR);
102 gpu_info->gl_extensions = gfx::GetGLExtensionsFromCurrentContext(); 103 gpu_info->gl_extensions = gfx::GetGLExtensionsFromCurrentContext();
103 gpu_info->gl_version = GetGLString(GL_VERSION); 104 gpu_info->gl_version = GetGLString(GL_VERSION);
104 std::string glsl_version_string = GetGLString(GL_SHADING_LANGUAGE_VERSION); 105 std::string glsl_version_string = GetGLString(GL_SHADING_LANGUAGE_VERSION);
106
107 gfx::GLVersionInfo gl_info(gpu_info->gl_version.c_str(),
108 gpu_info->gl_renderer.c_str(),
109 gpu_info->gl_extensions.c_str());
105 GLint max_samples = 0; 110 GLint max_samples = 0;
106 glGetIntegerv(GL_MAX_SAMPLES, &max_samples); 111 if (gl_info.IsAtLeastGL(3, 0) || gl_info.IsAtLeastGLES(3, 0) ||
112 gpu_info->gl_extensions.find("GL_ANGLE_framebuffer_multisample") !=
113 std::string::npos ||
114 gpu_info->gl_extensions.find("GL_APPLE_framebuffer_multisample") !=
115 std::string::npos ||
116 gpu_info->gl_extensions.find("GL_EXT_framebuffer_multisample") !=
117 std::string::npos ||
118 gpu_info->gl_extensions.find("GL_EXT_multisampled_render_to_texture") !=
119 std::string::npos ||
120 gpu_info->gl_extensions.find("GL_NV_framebuffer_multisample") !=
121 std::string::npos)
122 glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
Zhenyao Mo 2015/12/02 00:53:07 nit: with multi-line condition, add { } around the
107 gpu_info->max_msaa_samples = base::IntToString(max_samples); 123 gpu_info->max_msaa_samples = base::IntToString(max_samples);
108 UMA_HISTOGRAM_SPARSE_SLOWLY("GPU.MaxMSAASampleCount", max_samples); 124 UMA_HISTOGRAM_SPARSE_SLOWLY("GPU.MaxMSAASampleCount", max_samples);
109 125
110 gfx::GLWindowSystemBindingInfo window_system_binding_info; 126 gfx::GLWindowSystemBindingInfo window_system_binding_info;
111 if (GetGLWindowSystemBindingInfo(&window_system_binding_info)) { 127 if (GetGLWindowSystemBindingInfo(&window_system_binding_info)) {
112 gpu_info->gl_ws_vendor = window_system_binding_info.vendor; 128 gpu_info->gl_ws_vendor = window_system_binding_info.vendor;
113 gpu_info->gl_ws_version = window_system_binding_info.version; 129 gpu_info->gl_ws_version = window_system_binding_info.version;
114 gpu_info->gl_ws_extensions = window_system_binding_info.extensions; 130 gpu_info->gl_ws_extensions = window_system_binding_info.extensions;
115 gpu_info->direct_rendering = window_system_binding_info.direct_rendering; 131 gpu_info->direct_rendering = window_system_binding_info.direct_rendering;
116 } 132 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 basic_gpu_info->video_decode_accelerator_supported_profiles = 184 basic_gpu_info->video_decode_accelerator_supported_profiles =
169 context_gpu_info.video_decode_accelerator_supported_profiles; 185 context_gpu_info.video_decode_accelerator_supported_profiles;
170 basic_gpu_info->video_encode_accelerator_supported_profiles = 186 basic_gpu_info->video_encode_accelerator_supported_profiles =
171 context_gpu_info.video_encode_accelerator_supported_profiles; 187 context_gpu_info.video_encode_accelerator_supported_profiles;
172 basic_gpu_info->jpeg_decode_accelerator_supported = 188 basic_gpu_info->jpeg_decode_accelerator_supported =
173 context_gpu_info.jpeg_decode_accelerator_supported; 189 context_gpu_info.jpeg_decode_accelerator_supported;
174 } 190 }
175 191
176 } // namespace gpu 192 } // namespace gpu
177 193
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698