| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <set> | 5 #include <set> |
| 6 #include <string> | 6 #include <string> |
| 7 #include "gpu/command_buffer/service/feature_info.h" | 7 #include "gpu/command_buffer/service/feature_info.h" |
| 8 #include "gpu/command_buffer/service/gl_utils.h" | 8 #include "gpu/command_buffer/service/gl_utils.h" |
| 9 #include "ui/gfx/gl/gl_context.h" |
| 9 #include "ui/gfx/gl/gl_implementation.h" | 10 #include "ui/gfx/gl/gl_implementation.h" |
| 10 #include "ui/gfx/gl/gl_surface.h" | |
| 11 | 11 |
| 12 namespace gpu { | 12 namespace gpu { |
| 13 namespace gles2 { | 13 namespace gles2 { |
| 14 | 14 |
| 15 FeatureInfo::FeatureInfo() { | 15 FeatureInfo::FeatureInfo() { |
| 16 } | 16 } |
| 17 | 17 |
| 18 FeatureInfo::~FeatureInfo() { | 18 FeatureInfo::~FeatureInfo() { |
| 19 } | 19 } |
| 20 | 20 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 bool FeatureInfo::Initialize(const DisallowedFeatures& disallowed_features, | 90 bool FeatureInfo::Initialize(const DisallowedFeatures& disallowed_features, |
| 91 const char* allowed_features) { | 91 const char* allowed_features) { |
| 92 disallowed_features_ = disallowed_features; | 92 disallowed_features_ = disallowed_features; |
| 93 AddFeatures(allowed_features); | 93 AddFeatures(allowed_features); |
| 94 return true; | 94 return true; |
| 95 } | 95 } |
| 96 | 96 |
| 97 void FeatureInfo::AddFeatures(const char* desired_features) { | 97 void FeatureInfo::AddFeatures(const char* desired_features) { |
| 98 // Figure out what extensions to turn on. | 98 // Figure out what extensions to turn on. |
| 99 ExtensionHelper ext( | 99 ExtensionHelper ext( |
| 100 reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)), | 100 // Some unittests execute without a context made current |
| 101 // so fall back to glGetString |
| 102 gfx::GLContext::GetCurrent() ? |
| 103 gfx::GLContext::GetCurrent()->GetExtensions().c_str() : |
| 104 reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)), |
| 101 desired_features); | 105 desired_features); |
| 102 | 106 |
| 103 bool npot_ok = false; | 107 bool npot_ok = false; |
| 104 | 108 |
| 105 AddExtensionString("GL_CHROMIUM_resource_safe"); | 109 AddExtensionString("GL_CHROMIUM_resource_safe"); |
| 106 AddExtensionString("GL_CHROMIUM_resize"); | 110 AddExtensionString("GL_CHROMIUM_resize"); |
| 107 AddExtensionString("GL_CHROMIUM_strict_attribs"); | 111 AddExtensionString("GL_CHROMIUM_strict_attribs"); |
| 108 AddExtensionString("GL_CHROMIUM_swapbuffers_complete_callback"); | 112 AddExtensionString("GL_CHROMIUM_swapbuffers_complete_callback"); |
| 109 AddExtensionString("GL_CHROMIUM_rate_limit_offscreen_context"); | 113 AddExtensionString("GL_CHROMIUM_rate_limit_offscreen_context"); |
| 110 AddExtensionString("GL_CHROMIUM_set_visibility"); | 114 AddExtensionString("GL_CHROMIUM_set_visibility"); |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 | 356 |
| 353 // TODO(gman): Add support for these extensions. | 357 // TODO(gman): Add support for these extensions. |
| 354 // GL_OES_depth32 | 358 // GL_OES_depth32 |
| 355 // GL_OES_element_index_uint | 359 // GL_OES_element_index_uint |
| 356 | 360 |
| 357 feature_flags_.enable_texture_float_linear = enable_texture_float_linear; | 361 feature_flags_.enable_texture_float_linear = enable_texture_float_linear; |
| 358 feature_flags_.enable_texture_half_float_linear = | 362 feature_flags_.enable_texture_half_float_linear = |
| 359 enable_texture_half_float_linear; | 363 enable_texture_half_float_linear; |
| 360 feature_flags_.npot_ok = npot_ok; | 364 feature_flags_.npot_ok = npot_ok; |
| 361 | 365 |
| 362 if (ext.Desire("GL_CHROMIUM_post_sub_buffer") && | 366 if (ext.HaveAndDesire("GL_CHROMIUM_post_sub_buffer")) { |
| 363 gfx::GLSurface::GetCurrent() && | |
| 364 gfx::GLSurface::GetCurrent()->SupportsPostSubBuffer()) { | |
| 365 AddExtensionString("GL_CHROMIUM_post_sub_buffer"); | 367 AddExtensionString("GL_CHROMIUM_post_sub_buffer"); |
| 366 } | 368 } |
| 367 } | 369 } |
| 368 | 370 |
| 369 void FeatureInfo::AddExtensionString(const std::string& str) { | 371 void FeatureInfo::AddExtensionString(const std::string& str) { |
| 370 if (extensions_.find(str) == std::string::npos) { | 372 if (extensions_.find(str) == std::string::npos) { |
| 371 extensions_ += (extensions_.empty() ? "" : " ") + str; | 373 extensions_ += (extensions_.empty() ? "" : " ") + str; |
| 372 } | 374 } |
| 373 } | 375 } |
| 374 | 376 |
| 375 } // namespace gles2 | 377 } // namespace gles2 |
| 376 } // namespace gpu | 378 } // namespace gpu |
| OLD | NEW |