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

Unified Diff: gpu/command_buffer/service/feature_info.cc

Issue 11791032: Refactor FeatureInfo so you can't request features. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/command_buffer/service/feature_info.h ('k') | gpu/command_buffer/service/feature_info_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/service/feature_info.cc
diff --git a/gpu/command_buffer/service/feature_info.cc b/gpu/command_buffer/service/feature_info.cc
index a7ca864576f3394cfd6a296a7497ea8559146190..0114d14b48cf1d2fe1f62f9184b8c8bfbe67af97 100644
--- a/gpu/command_buffer/service/feature_info.cc
+++ b/gpu/command_buffer/service/feature_info.cc
@@ -71,7 +71,6 @@ FeatureInfo::FeatureFlags::FeatureFlags()
npot_ok(false),
enable_texture_float_linear(false),
enable_texture_half_float_linear(false),
- chromium_webglsl(false),
chromium_stream_texture(false),
angle_translated_shader_source(false),
angle_pack_reverse_row_order(false),
@@ -132,69 +131,23 @@ FeatureInfo::FeatureInfo() {
}
}
-// Helps query for extensions.
-class ExtensionHelper {
- public:
- ExtensionHelper(const char* extensions, const char* desired_features)
- : desire_all_features_(false) {
- // Check for "*"
- if (desired_features &&
- desired_features[0] == '*' &&
- desired_features[1] == '\0') {
- desired_features = NULL;
- }
-
- have_extensions_.Init(extensions);
- desired_extensions_.Init(desired_features);
-
- if (!desired_features) {
- desire_all_features_ = true;
- }
- }
-
- // Returns true if extension exists.
- bool Have(const char* extension) {
- return have_extensions_.Contains(extension);
- }
-
- // Returns true of an extension is desired. It may not exist.
- bool Desire(const char* extension) {
- return desire_all_features_ || desired_extensions_.Contains(extension);
- }
-
- // Returns true if an extension exists and is desired.
- bool HaveAndDesire(const char* extension) {
- return Have(extension) && Desire(extension);
- }
-
- private:
- bool desire_all_features_;
-
- // Extensions that exist.
- StringSet have_extensions_;
-
- // Extensions that are desired but may not exist.
- StringSet desired_extensions_;
-};
-
bool FeatureInfo::Initialize(const char* allowed_features) {
disallowed_features_ = DisallowedFeatures();
- AddFeatures(allowed_features);
+ AddFeatures();
return true;
}
bool FeatureInfo::Initialize(const DisallowedFeatures& disallowed_features,
const char* allowed_features) {
disallowed_features_ = disallowed_features;
- AddFeatures(allowed_features);
+ AddFeatures();
return true;
}
-void FeatureInfo::AddFeatures(const char* desired_features) {
+void FeatureInfo::AddFeatures() {
// Figure out what extensions to turn on.
- ExtensionHelper ext(
- reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)),
- desired_features);
+ StringSet extensions(
+ reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)));
// NOTE: We need to check both GL_VENDOR and GL_RENDERER because for example
// Sandy Bridge on Linux reports:
@@ -251,39 +204,41 @@ void FeatureInfo::AddFeatures(const char* desired_features) {
AddExtensionString("GL_CHROMIUM_resource_safe");
AddExtensionString("GL_CHROMIUM_set_visibility");
AddExtensionString("GL_CHROMIUM_strict_attribs");
+ AddExtensionString("GL_CHROMIUM_stream_texture");
AddExtensionString("GL_CHROMIUM_texture_mailbox");
AddExtensionString("GL_EXT_debug_marker");
+ feature_flags_.chromium_stream_texture = true;
+
+ // OES_vertex_array_object is emulated if not present natively,
+ // so the extension string is always exposed.
+ AddExtensionString("GL_OES_vertex_array_object");
+
if (!disallowed_features_.gpu_memory_manager)
AddExtensionString("GL_CHROMIUM_gpu_memory_manager");
- if (ext.Have("GL_ANGLE_translated_shader_source")) {
+ if (extensions.Contains("GL_ANGLE_translated_shader_source")) {
feature_flags_.angle_translated_shader_source = true;
}
- // Only turn this feature on if it is requested. Not by default.
- if (desired_features && ext.Desire("GL_CHROMIUM_webglsl")) {
- AddExtensionString("GL_CHROMIUM_webglsl");
- feature_flags_.chromium_webglsl = true;
- }
-
// Check if we should allow GL_EXT_texture_compression_dxt1 and
// GL_EXT_texture_compression_s3tc.
bool enable_dxt1 = false;
bool enable_dxt3 = false;
bool enable_dxt5 = false;
- bool have_s3tc = ext.Have("GL_EXT_texture_compression_s3tc");
- bool have_dxt3 = have_s3tc || ext.Have("GL_ANGLE_texture_compression_dxt3");
- bool have_dxt5 = have_s3tc || ext.Have("GL_ANGLE_texture_compression_dxt5");
+ bool have_s3tc = extensions.Contains("GL_EXT_texture_compression_s3tc");
+ bool have_dxt3 =
+ have_s3tc || extensions.Contains("GL_ANGLE_texture_compression_dxt3");
+ bool have_dxt5 =
+ have_s3tc || extensions.Contains("GL_ANGLE_texture_compression_dxt5");
- if (ext.Desire("GL_EXT_texture_compression_dxt1") &&
- (ext.Have("GL_EXT_texture_compression_dxt1") || have_s3tc)) {
+ if (extensions.Contains("GL_EXT_texture_compression_dxt1") || have_s3tc) {
enable_dxt1 = true;
}
- if (have_dxt3 && ext.Desire("GL_CHROMIUM_texture_compression_dxt3")) {
+ if (have_dxt3) {
enable_dxt3 = true;
}
- if (have_dxt5 && ext.Desire("GL_CHROMIUM_texture_compression_dxt5")) {
+ if (have_dxt5) {
enable_dxt5 = true;
}
@@ -314,7 +269,7 @@ void FeatureInfo::AddFeatures(const char* desired_features) {
}
// Check if we should enable GL_EXT_texture_filter_anisotropic.
- if (ext.HaveAndDesire("GL_EXT_texture_filter_anisotropic")) {
+ if (extensions.Contains("GL_EXT_texture_filter_anisotropic")) {
AddExtensionString("GL_EXT_texture_filter_anisotropic");
validators_.texture_parameter.AddValue(
GL_TEXTURE_MAX_ANISOTROPY_EXT);
@@ -335,11 +290,9 @@ void FeatureInfo::AddFeatures(const char* desired_features) {
// get rid of it.
//
bool enable_depth_texture = false;
- if ((ext.Desire("GL_GOOGLE_depth_texture") ||
- ext.Desire("GL_CHROMIUM_depth_texture")) &&
- (ext.Have("GL_ARB_depth_texture") ||
- ext.Have("GL_OES_depth_texture") ||
- ext.Have("GL_ANGLE_depth_texture"))) {
+ if (extensions.Contains("GL_ARB_depth_texture") ||
+ extensions.Contains("GL_OES_depth_texture") ||
+ extensions.Contains("GL_ANGLE_depth_texture")) {
enable_depth_texture = true;
}
@@ -354,9 +307,8 @@ void FeatureInfo::AddFeatures(const char* desired_features) {
validators_.pixel_type.AddValue(GL_UNSIGNED_INT);
}
- if (ext.Desire("GL_OES_packed_depth_stencil") &&
- (ext.Have("GL_EXT_packed_depth_stencil") ||
- ext.Have("GL_OES_packed_depth_stencil"))) {
+ if (extensions.Contains("GL_EXT_packed_depth_stencil") ||
+ extensions.Contains("GL_OES_packed_depth_stencil")) {
AddExtensionString("GL_OES_packed_depth_stencil");
if (enable_depth_texture) {
texture_format_validators_[GL_DEPTH_STENCIL].AddValue(
@@ -368,43 +320,34 @@ void FeatureInfo::AddFeatures(const char* desired_features) {
validators_.render_buffer_format.AddValue(GL_DEPTH24_STENCIL8);
}
- if (ext.Desire("GL_OES_vertex_array_object")) {
- if (ext.Have("GL_OES_vertex_array_object") ||
- ext.Have("GL_ARB_vertex_array_object") ||
- ext.Have("GL_APPLE_vertex_array_object")) {
- feature_flags_.native_vertex_array_object = true;
- }
-
- // OES_vertex_array_object is emulated if not present natively,
- // so the extension string is always exposed.
- AddExtensionString("GL_OES_vertex_array_object");
+ if (extensions.Contains("GL_OES_vertex_array_object") ||
+ extensions.Contains("GL_ARB_vertex_array_object") ||
+ extensions.Contains("GL_APPLE_vertex_array_object")) {
+ feature_flags_.native_vertex_array_object = true;
}
- if (ext.Desire("GL_OES_element_index_uint")) {
- if (ext.Have("GL_OES_element_index_uint") || gfx::HasDesktopGLFeatures()) {
- AddExtensionString("GL_OES_element_index_uint");
- validators_.index_type.AddValue(GL_UNSIGNED_INT);
- }
+ if (extensions.Contains("GL_OES_element_index_uint") ||
+ gfx::HasDesktopGLFeatures()) {
+ AddExtensionString("GL_OES_element_index_uint");
+ validators_.index_type.AddValue(GL_UNSIGNED_INT);
}
bool enable_texture_format_bgra8888 = false;
bool enable_read_format_bgra = false;
// Check if we should allow GL_EXT_texture_format_BGRA8888
- if (ext.Desire("GL_EXT_texture_format_BGRA8888") &&
- (ext.Have("GL_EXT_texture_format_BGRA8888") ||
- ext.Have("GL_APPLE_texture_format_BGRA8888") ||
- ext.Have("GL_EXT_bgra"))) {
+ if (extensions.Contains("GL_EXT_texture_format_BGRA8888") ||
+ extensions.Contains("GL_APPLE_texture_format_BGRA8888") ||
+ extensions.Contains("GL_EXT_bgra")) {
enable_texture_format_bgra8888 = true;
}
- if (ext.HaveAndDesire("GL_EXT_bgra")) {
+ if (extensions.Contains("GL_EXT_bgra")) {
enable_texture_format_bgra8888 = true;
enable_read_format_bgra = true;
}
- if (ext.Desire("GL_EXT_read_format_bgra") &&
- (ext.Have("GL_EXT_read_format_bgra") ||
- ext.Have("GL_EXT_bgra"))) {
+ if (extensions.Contains("GL_EXT_read_format_bgra") ||
+ extensions.Contains("GL_EXT_bgra")) {
enable_read_format_bgra = true;
}
@@ -420,18 +363,15 @@ void FeatureInfo::AddFeatures(const char* desired_features) {
validators_.read_pixel_format.AddValue(GL_BGRA_EXT);
}
- if (ext.Desire("GL_OES_rgb8_rgba8")) {
- if (ext.Have("GL_OES_rgb8_rgba8") || gfx::HasDesktopGLFeatures()) {
- AddExtensionString("GL_OES_rgb8_rgba8");
- validators_.render_buffer_format.AddValue(GL_RGB8_OES);
- validators_.render_buffer_format.AddValue(GL_RGBA8_OES);
- }
+ if (extensions.Contains("GL_OES_rgb8_rgba8") || gfx::HasDesktopGLFeatures()) {
+ AddExtensionString("GL_OES_rgb8_rgba8");
+ validators_.render_buffer_format.AddValue(GL_RGB8_OES);
+ validators_.render_buffer_format.AddValue(GL_RGBA8_OES);
}
// Check if we should allow GL_OES_texture_npot
- if (ext.Desire("GL_OES_texture_npot") &&
- (ext.Have("GL_ARB_texture_non_power_of_two") ||
- ext.Have("GL_OES_texture_npot"))) {
+ if (extensions.Contains("GL_ARB_texture_non_power_of_two") ||
+ extensions.Contains("GL_OES_texture_npot")) {
AddExtensionString("GL_OES_texture_npot");
npot_ok = true;
}
@@ -443,31 +383,26 @@ void FeatureInfo::AddFeatures(const char* desired_features) {
bool enable_texture_half_float = false;
bool enable_texture_half_float_linear = false;
- bool have_arb_texture_float = ext.Have("GL_ARB_texture_float");
+ bool have_arb_texture_float = extensions.Contains("GL_ARB_texture_float");
- if (have_arb_texture_float && ext.Desire("GL_ARB_texture_float")) {
+ if (have_arb_texture_float) {
enable_texture_float = true;
enable_texture_float_linear = true;
enable_texture_half_float = true;
enable_texture_half_float_linear = true;
} else {
- if (ext.HaveAndDesire("GL_OES_texture_float") ||
- (have_arb_texture_float &&
- ext.Desire("GL_OES_texture_float"))) {
+ if (extensions.Contains("GL_OES_texture_float") || have_arb_texture_float) {
enable_texture_float = true;
- if (ext.HaveAndDesire("GL_OES_texture_float_linear") ||
- (have_arb_texture_float &&
- ext.Desire("GL_OES_texture_float_linear"))) {
+ if (extensions.Contains("GL_OES_texture_float_linear") ||
+ have_arb_texture_float) {
enable_texture_float_linear = true;
}
}
- if (ext.HaveAndDesire("GL_OES_texture_half_float") ||
- (have_arb_texture_float &&
- ext.Desire("GL_OES_texture_half_float"))) {
+ if (extensions.Contains("GL_OES_texture_half_float") ||
+ have_arb_texture_float) {
enable_texture_half_float = true;
- if (ext.HaveAndDesire("GL_OES_texture_half_float_linear") ||
- (have_arb_texture_float &&
- ext.Desire("GL_OES_texture_half_float_linear"))) {
+ if (extensions.Contains("GL_OES_texture_half_float_linear") ||
+ have_arb_texture_float) {
enable_texture_half_float_linear = true;
}
}
@@ -502,15 +437,15 @@ void FeatureInfo::AddFeatures(const char* desired_features) {
}
// Check for multisample support
- bool ext_has_multisample = ext.Have("GL_EXT_framebuffer_multisample");
+ bool ext_has_multisample =
+ extensions.Contains("GL_EXT_framebuffer_multisample");
if (!is_qualcomm || feature_flags_.disable_workarounds) {
// Some Android Qualcomm drivers falsely report this ANGLE extension string.
// See http://crbug.com/165736
- ext_has_multisample |= ext.Have("GL_ANGLE_framebuffer_multisample");
+ ext_has_multisample |=
+ extensions.Contains("GL_ANGLE_framebuffer_multisample");
}
- if (!disallowed_features_.multisampling &&
- ext.Desire("GL_CHROMIUM_framebuffer_multisample") &&
- ext_has_multisample) {
+ if (!disallowed_features_.multisampling && ext_has_multisample) {
feature_flags_.chromium_framebuffer_multisample = true;
validators_.frame_buffer_target.AddValue(GL_READ_FRAMEBUFFER_EXT);
validators_.frame_buffer_target.AddValue(GL_DRAW_FRAMEBUFFER_EXT);
@@ -520,22 +455,20 @@ void FeatureInfo::AddFeatures(const char* desired_features) {
AddExtensionString("GL_CHROMIUM_framebuffer_multisample");
}
- if (ext.HaveAndDesire("GL_OES_depth24") ||
- (gfx::HasDesktopGLFeatures() && ext.Desire("GL_OES_depth24"))) {
+ if (extensions.Contains("GL_OES_depth24") || gfx::HasDesktopGLFeatures()) {
AddExtensionString("GL_OES_depth24");
validators_.render_buffer_format.AddValue(GL_DEPTH_COMPONENT24);
}
- if (ext.HaveAndDesire("GL_OES_standard_derivatives") ||
- (gfx::HasDesktopGLFeatures() &&
- ext.Desire("GL_OES_standard_derivatives"))) {
+ if (extensions.Contains("GL_OES_standard_derivatives") ||
+ gfx::HasDesktopGLFeatures()) {
AddExtensionString("GL_OES_standard_derivatives");
feature_flags_.oes_standard_derivatives = true;
validators_.hint_target.AddValue(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES);
validators_.g_l_state.AddValue(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES);
}
- if (ext.HaveAndDesire("GL_OES_EGL_image_external")) {
+ if (extensions.Contains("GL_OES_EGL_image_external")) {
AddExtensionString("GL_OES_EGL_image_external");
feature_flags_.oes_egl_image_external = true;
validators_.texture_bind_target.AddValue(GL_TEXTURE_EXTERNAL_OES);
@@ -544,22 +477,17 @@ void FeatureInfo::AddFeatures(const char* desired_features) {
validators_.g_l_state.AddValue(GL_TEXTURE_BINDING_EXTERNAL_OES);
}
- if (ext.HaveAndDesire("GL_OES_compressed_ETC1_RGB8_texture")) {
+ if (extensions.Contains("GL_OES_compressed_ETC1_RGB8_texture")) {
AddExtensionString("GL_OES_compressed_ETC1_RGB8_texture");
validators_.compressed_texture_format.AddValue(GL_ETC1_RGB8_OES);
}
- if (ext.Desire("GL_CHROMIUM_stream_texture")) {
- AddExtensionString("GL_CHROMIUM_stream_texture");
- feature_flags_.chromium_stream_texture = true;
- }
-
// Ideally we would only expose this extension on Mac OS X, to
// support GL_CHROMIUM_iosurface and the compositor. We don't want
// applications to start using it; they should use ordinary non-
// power-of-two textures. However, for unit testing purposes we
// expose it on all supported platforms.
- if (ext.HaveAndDesire("GL_ARB_texture_rectangle")) {
+ if (extensions.Contains("GL_ARB_texture_rectangle")) {
AddExtensionString("GL_ARB_texture_rectangle");
feature_flags_.arb_texture_rectangle = true;
validators_.texture_bind_target.AddValue(GL_TEXTURE_RECTANGLE_ARB);
@@ -586,20 +514,19 @@ void FeatureInfo::AddFeatures(const char* desired_features) {
enable_texture_half_float_linear;
feature_flags_.npot_ok |= npot_ok;
- if (ext.Desire("GL_ANGLE_pack_reverse_row_order") &&
- ext.Have("GL_ANGLE_pack_reverse_row_order")) {
+ if (extensions.Contains("GL_ANGLE_pack_reverse_row_order")) {
AddExtensionString("GL_ANGLE_pack_reverse_row_order");
feature_flags_.angle_pack_reverse_row_order = true;
validators_.pixel_store.AddValue(GL_PACK_REVERSE_ROW_ORDER_ANGLE);
validators_.g_l_state.AddValue(GL_PACK_REVERSE_ROW_ORDER_ANGLE);
}
- if (ext.HaveAndDesire("GL_ANGLE_texture_usage")) {
+ if (extensions.Contains("GL_ANGLE_texture_usage")) {
AddExtensionString("GL_ANGLE_texture_usage");
validators_.texture_parameter.AddValue(GL_TEXTURE_USAGE_ANGLE);
}
- if (ext.HaveAndDesire("GL_EXT_texture_storage")) {
+ if (extensions.Contains("GL_EXT_texture_storage")) {
AddExtensionString("GL_EXT_texture_storage");
validators_.texture_parameter.AddValue(GL_TEXTURE_IMMUTABLE_FORMAT_EXT);
if (enable_texture_format_bgra8888)
@@ -625,9 +552,11 @@ void FeatureInfo::AddFeatures(const char* desired_features) {
}
bool have_ext_occlusion_query_boolean =
- ext.Have("GL_EXT_occlusion_query_boolean");
- bool have_arb_occlusion_query2 = ext.Have("GL_ARB_occlusion_query2");
- bool have_arb_occlusion_query = ext.Have("GL_ARB_occlusion_query");
+ extensions.Contains("GL_EXT_occlusion_query_boolean");
+ bool have_arb_occlusion_query2 =
+ extensions.Contains("GL_ARB_occlusion_query2");
+ bool have_arb_occlusion_query =
+ extensions.Contains("GL_ARB_occlusion_query");
bool ext_occlusion_query_disallowed = false;
#if defined(OS_LINUX)
@@ -638,7 +567,6 @@ void FeatureInfo::AddFeatures(const char* desired_features) {
#endif
if (!ext_occlusion_query_disallowed &&
- ext.Desire("GL_EXT_occlusion_query_boolean") &&
(have_ext_occlusion_query_boolean ||
have_arb_occlusion_query2 ||
have_arb_occlusion_query)) {
@@ -651,10 +579,9 @@ void FeatureInfo::AddFeatures(const char* desired_features) {
!have_arb_occlusion_query2;
}
- if (ext.Desire("GL_ANGLE_instanced_arrays") &&
- (ext.Have("GL_ANGLE_instanced_arrays") ||
- (ext.Have("GL_ARB_instanced_arrays") &&
- ext.Have("GL_ARB_draw_instanced")))) {
+ if (extensions.Contains("GL_ANGLE_instanced_arrays") ||
+ (extensions.Contains("GL_ARB_instanced_arrays") &&
+ extensions.Contains("GL_ARB_draw_instanced"))) {
AddExtensionString("GL_ANGLE_instanced_arrays");
feature_flags_.angle_instanced_arrays = true;
validators_.vertex_attribute.AddValue(GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE);
« no previous file with comments | « gpu/command_buffer/service/feature_info.h ('k') | gpu/command_buffer/service/feature_info_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698