diff options
Diffstat (limited to 'chromium/ui/gl')
106 files changed, 1612 insertions, 954 deletions
diff --git a/chromium/ui/gl/BUILD.gn b/chromium/ui/gl/BUILD.gn index e2dac179caf..760c94378f2 100644 --- a/chromium/ui/gl/BUILD.gn +++ b/chromium/ui/gl/BUILD.gn @@ -45,8 +45,6 @@ component("gl") { output_name = "gl_wrapper" # Avoid colliding with OS X"s libGL.dylib. sources = [ - "android/gl_jni_registrar.cc", - "android/gl_jni_registrar.h", "android/scoped_java_surface.cc", "android/scoped_java_surface.h", "android/surface_texture.cc", @@ -57,6 +55,8 @@ component("gl") { "ca_renderer_layer_params.h", "dc_renderer_layer_params.cc", "dc_renderer_layer_params.h", + "extension_set.cc", + "extension_set.h", "gl_bindings.cc", "gl_bindings.h", "gl_bindings_autogen_gl.cc", @@ -262,6 +262,7 @@ component("gl") { "//third_party/angle:libEGL", "//third_party/angle:libGLESv2", "//third_party/mesa:osmesa", + "//third_party/swiftshader", ] deps += [ "//third_party/angle:includes" ] @@ -375,7 +376,11 @@ source_set("run_all_unittests") { ] if (use_ozone) { - deps += [ "//ui/ozone" ] + deps += [ + "//mojo/edk/system", + "//services/service_manager/public/cpp/test:test_support", + "//ui/ozone", + ] } } diff --git a/chromium/ui/gl/android/scoped_java_surface.cc b/chromium/ui/gl/android/scoped_java_surface.cc index 1f0501bd687..bbe2d396891 100644 --- a/chromium/ui/gl/android/scoped_java_surface.cc +++ b/chromium/ui/gl/android/scoped_java_surface.cc @@ -20,7 +20,7 @@ ScopedJavaSurface::ScopedJavaSurface( : auto_release_(true), is_protected_(false) { JNIEnv* env = base::android::AttachCurrentThread(); - DCHECK(env->IsInstanceOf(surface.obj(), Surface_clazz(env))); + DCHECK(env->IsInstanceOf(surface.obj(), android_view_Surface_clazz(env))); j_surface_.Reset(surface); } diff --git a/chromium/ui/gl/android/surface_texture_listener.cc b/chromium/ui/gl/android/surface_texture_listener.cc index 5b2c713aeae..091facced5e 100644 --- a/chromium/ui/gl/android/surface_texture_listener.cc +++ b/chromium/ui/gl/android/surface_texture_listener.cc @@ -38,9 +38,4 @@ void SurfaceTextureListener::FrameAvailable(JNIEnv* env, } } -// static -bool SurfaceTextureListener::RegisterSurfaceTextureListener(JNIEnv* env) { - return RegisterNativesImpl(env); -} - } // namespace gl diff --git a/chromium/ui/gl/android/surface_texture_listener.h b/chromium/ui/gl/android/surface_texture_listener.h index 6e2080daf35..d0221858778 100644 --- a/chromium/ui/gl/android/surface_texture_listener.h +++ b/chromium/ui/gl/android/surface_texture_listener.h @@ -30,8 +30,6 @@ class GL_EXPORT SurfaceTextureListener { void FrameAvailable(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); - static bool RegisterSurfaceTextureListener(JNIEnv* env); - private: friend class base::DeleteHelper<SurfaceTextureListener>; diff --git a/chromium/ui/gl/angle_platform_impl.cc b/chromium/ui/gl/angle_platform_impl.cc index 1363fb97b4e..3e6f4903b6e 100644 --- a/chromium/ui/gl/angle_platform_impl.cc +++ b/chromium/ui/gl/angle_platform_impl.cc @@ -4,45 +4,55 @@ #include "ui/gl/angle_platform_impl.h" +#include "base/base64.h" +#include "base/callback.h" +#include "base/lazy_instance.h" #include "base/metrics/histogram.h" #include "base/metrics/histogram_macros.h" #include "base/trace_event/trace_event.h" #include "third_party/angle/include/platform/Platform.h" #include "ui/gl/gl_bindings.h" -namespace gl { +namespace angle { namespace { -angle::ResetDisplayPlatformFunc g_angle_reset_platform = nullptr; +// This platform context stores user data accessible inside the impl methods. +struct PlatformContext { + CacheProgramCallback cache_program_callback; +}; -double ANGLEPlatformImpl_currentTime(angle::PlatformMethods* platform) { +base::LazyInstance<PlatformContext>::DestructorAtExit g_platform_context = + LAZY_INSTANCE_INITIALIZER; +ResetDisplayPlatformFunc g_angle_reset_platform = nullptr; + +double ANGLEPlatformImpl_currentTime(PlatformMethods* platform) { return base::Time::Now().ToDoubleT(); } double ANGLEPlatformImpl_monotonicallyIncreasingTime( - angle::PlatformMethods* platform) { + PlatformMethods* platform) { return (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF(); } const unsigned char* ANGLEPlatformImpl_getTraceCategoryEnabledFlag( - angle::PlatformMethods* platform, + PlatformMethods* platform, const char* category_group) { return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(category_group); } -void ANGLEPlatformImpl_logError(angle::PlatformMethods* platform, +void ANGLEPlatformImpl_logError(PlatformMethods* platform, const char* errorMessage) { LOG(ERROR) << errorMessage; } -void ANGLEPlatformImpl_logWarning(angle::PlatformMethods* platform, +void ANGLEPlatformImpl_logWarning(PlatformMethods* platform, const char* warningMessage) { LOG(WARNING) << warningMessage; } -angle::TraceEventHandle ANGLEPlatformImpl_addTraceEvent( - angle::PlatformMethods* platform, +TraceEventHandle ANGLEPlatformImpl_addTraceEvent( + PlatformMethods* platform, char phase, const unsigned char* category_group_enabled, const char* name, @@ -61,23 +71,23 @@ angle::TraceEventHandle ANGLEPlatformImpl_addTraceEvent( trace_event_internal::kGlobalScope, id, trace_event_internal::kNoId, base::PlatformThread::CurrentId(), timestamp_tt, num_args, arg_names, arg_types, arg_values, nullptr, flags); - angle::TraceEventHandle result; + TraceEventHandle result; memcpy(&result, &handle, sizeof(result)); return result; } void ANGLEPlatformImpl_updateTraceEventDuration( - angle::PlatformMethods* platform, + PlatformMethods* platform, const unsigned char* category_group_enabled, const char* name, - angle::TraceEventHandle handle) { + TraceEventHandle handle) { base::trace_event::TraceEventHandle trace_event_handle; memcpy(&trace_event_handle, &handle, sizeof(handle)); TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled, name, trace_event_handle); } -void ANGLEPlatformImpl_histogramCustomCounts(angle::PlatformMethods* platform, +void ANGLEPlatformImpl_histogramCustomCounts(PlatformMethods* platform, const char* name, int sample, int min, @@ -92,7 +102,7 @@ void ANGLEPlatformImpl_histogramCustomCounts(angle::PlatformMethods* platform, counter->Add(sample); } -void ANGLEPlatformImpl_histogramEnumeration(angle::PlatformMethods* platform, +void ANGLEPlatformImpl_histogramEnumeration(PlatformMethods* platform, const char* name, int sample, int boundary_value) { @@ -105,7 +115,7 @@ void ANGLEPlatformImpl_histogramEnumeration(angle::PlatformMethods* platform, counter->Add(sample); } -void ANGLEPlatformImpl_histogramSparse(angle::PlatformMethods* platform, +void ANGLEPlatformImpl_histogramSparse(PlatformMethods* platform, const char* name, int sample) { // For sparse histograms, we can use the macro, as it does not incorporate a @@ -113,30 +123,49 @@ void ANGLEPlatformImpl_histogramSparse(angle::PlatformMethods* platform, UMA_HISTOGRAM_SPARSE_SLOWLY(name, sample); } -void ANGLEPlatformImpl_histogramBoolean(angle::PlatformMethods* platform, +void ANGLEPlatformImpl_histogramBoolean(PlatformMethods* platform, const char* name, bool sample) { ANGLEPlatformImpl_histogramEnumeration(platform, name, sample ? 1 : 0, 2); } +void ANGLEPlatformImpl_cacheProgram(PlatformMethods* platform, + const ProgramKeyType& key, + size_t program_size, + const uint8_t* program_bytes) { + PlatformContext* context = + reinterpret_cast<PlatformContext*>(platform->context); + if (context && context->cache_program_callback) { + // Convert the key and binary to string form. + std::string key_string(reinterpret_cast<const char*>(&key[0]), + sizeof(ProgramKeyType)); + std::string value_string(reinterpret_cast<const char*>(program_bytes), + program_size); + std::string key_string_64; + std::string value_string_64; + base::Base64Encode(key_string, &key_string_64); + base::Base64Encode(value_string, &value_string_64); + context->cache_program_callback.Run(key_string_64, value_string_64); + } +} + } // anonymous namespace -bool InitializeANGLEPlatform(EGLDisplay display) { - angle::GetDisplayPlatformFunc angle_get_platform = - reinterpret_cast<angle::GetDisplayPlatformFunc>( +bool InitializePlatform(EGLDisplay display) { + GetDisplayPlatformFunc angle_get_platform = + reinterpret_cast<GetDisplayPlatformFunc>( eglGetProcAddress("ANGLEGetDisplayPlatform")); if (!angle_get_platform) return false; // Save the pointer to the destroy function here to avoid crash. - g_angle_reset_platform = reinterpret_cast<angle::ResetDisplayPlatformFunc>( + g_angle_reset_platform = reinterpret_cast<ResetDisplayPlatformFunc>( eglGetProcAddress("ANGLEResetDisplayPlatform")); - angle::PlatformMethods* platformMethods = nullptr; - if (!angle_get_platform(static_cast<angle::EGLDisplayType>(display), - angle::g_PlatformMethodNames, - angle::g_NumPlatformMethods, nullptr, - &platformMethods)) + PlatformMethods* platformMethods = nullptr; + if (!angle_get_platform(static_cast<EGLDisplayType>(display), + g_PlatformMethodNames, g_NumPlatformMethods, + &g_platform_context.Get(), &platformMethods)) return false; platformMethods->currentTime = ANGLEPlatformImpl_currentTime; platformMethods->addTraceEvent = ANGLEPlatformImpl_addTraceEvent; @@ -155,13 +184,23 @@ bool InitializeANGLEPlatform(EGLDisplay display) { ANGLEPlatformImpl_monotonicallyIncreasingTime; platformMethods->updateTraceEventDuration = ANGLEPlatformImpl_updateTraceEventDuration; + platformMethods->cacheProgram = ANGLEPlatformImpl_cacheProgram; return true; } -void ResetANGLEPlatform(EGLDisplay display) { +void ResetPlatform(EGLDisplay display) { if (!g_angle_reset_platform) return; - g_angle_reset_platform(static_cast<angle::EGLDisplayType>(display)); + g_angle_reset_platform(static_cast<EGLDisplayType>(display)); + ResetCacheProgramCallback(); +} + +void SetCacheProgramCallback(CacheProgramCallback callback) { + g_platform_context.Get().cache_program_callback = callback; +} + +void ResetCacheProgramCallback() { + g_platform_context.Get().cache_program_callback.Reset(); } -} // namespace gl +} // namespace angle diff --git a/chromium/ui/gl/angle_platform_impl.h b/chromium/ui/gl/angle_platform_impl.h index 38c93ab678a..927850cc7f0 100644 --- a/chromium/ui/gl/angle_platform_impl.h +++ b/chromium/ui/gl/angle_platform_impl.h @@ -8,13 +8,20 @@ // Implements the ANGLE platform interface, for functionality like // histograms and trace profiling. +#include "base/callback_forward.h" #include "ui/gl/gl_context_egl.h" +#include "ui/gl/gl_export.h" -namespace gl { +namespace angle { -bool InitializeANGLEPlatform(EGLDisplay display); -void ResetANGLEPlatform(EGLDisplay display); +GL_EXPORT bool InitializePlatform(EGLDisplay display); +GL_EXPORT void ResetPlatform(EGLDisplay display); -} // namespace gl +using CacheProgramCallback = + base::RepeatingCallback<void(const std::string&, const std::string&)>; +GL_EXPORT void SetCacheProgramCallback(CacheProgramCallback callback); +GL_EXPORT void ResetCacheProgramCallback(); + +} // namespace angle #endif // UI_GL_ANGLE_PLATFORM_IMPL_H_ diff --git a/chromium/ui/gl/egl_api_unittest.cc b/chromium/ui/gl/egl_api_unittest.cc index 772cf0646a1..1d8babc927b 100644 --- a/chromium/ui/gl/egl_api_unittest.cc +++ b/chromium/ui/gl/egl_api_unittest.cc @@ -4,7 +4,6 @@ #include <memory> -#include "base/command_line.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/gl/gl_egl_api_implementation.h" #include "ui/gl/gl_surface_egl.h" @@ -26,6 +25,8 @@ class EGLApiTest : public testing::Test { g_driver_egl.fn.eglGetDisplayFn = &FakeGetDisplay; g_driver_egl.fn.eglGetErrorFn = &FakeGetError; g_driver_egl.fn.eglGetProcAddressFn = &FakeGetProcAddress; + + SetGLImplementation(kGLImplementationEGLGLES2); } void TearDown() override { @@ -37,13 +38,13 @@ class EGLApiTest : public testing::Test { fake_extension_string_ = ""; } - void InitializeAPI(base::CommandLine* command_line) { + void InitializeAPI(const char* disabled_extensions) { api_.reset(new RealEGLApi()); g_current_egl_context = api_.get(); - if (command_line) - api_->InitializeWithCommandLine(&g_driver_egl, command_line); - else - api_->Initialize(&g_driver_egl); + api_->Initialize(&g_driver_egl); + if (disabled_extensions) { + SetDisabledExtensionsEGL(disabled_extensions); + } g_driver_egl.InitializeClientExtensionBindings(); GLSurfaceEGL::InitializeDisplay(EGL_DEFAULT_DISPLAY); g_driver_egl.InitializeExtensionBindings(); @@ -114,23 +115,21 @@ TEST_F(EGLApiTest, DisabledExtensionBitTest) { EXPECT_TRUE(g_driver_egl.ext.b_EGL_KHR_fence_sync); - base::CommandLine command_line(base::CommandLine::NO_PROGRAM); - command_line.AppendSwitchASCII(switches::kDisableGLExtensions, - kFakeDisabledExtensions); - InitializeAPI(&command_line); + InitializeAPI(kFakeDisabledExtensions); EXPECT_FALSE(g_driver_egl.ext.b_EGL_KHR_fence_sync); } TEST_F(EGLApiTest, DisabledExtensionStringTest) { - static const char* kFakeExtensions = "EGL_EXT_1 EGL_EXT_2" - " EGL_EXT_3 EGL_EXT_4"; + static const char* kFakeExtensions = + "EGL_EXT_1 EGL_KHR_fence_sync EGL_EXT_3 EGL_KHR_wait_sync"; static const char* kFakeClientExtensions = "EGL_CLIENT_EXT_1 EGL_CLIENT_EXT_2"; static const char* kFakeDisabledExtensions = - "EGL_EXT_1,EGL_EXT_2,EGL_FAKE,EGL_CLIENT_EXT_1"; - static const char* kFilteredExtensions = "EGL_EXT_3 EGL_EXT_4"; - static const char* kFilteredClientExtensions = "EGL_CLIENT_EXT_2"; + "EGL_KHR_fence_sync,EGL_KHR_wait_sync"; + static const char* kFilteredExtensions = "EGL_EXT_1 EGL_EXT_3"; + static const char* kFilteredClientExtensions = + "EGL_CLIENT_EXT_1 EGL_CLIENT_EXT_2"; SetFakeExtensionString(kFakeExtensions, kFakeClientExtensions); InitializeAPI(nullptr); @@ -138,10 +137,7 @@ TEST_F(EGLApiTest, DisabledExtensionStringTest) { EXPECT_STREQ(kFakeClientExtensions, GetExtensions().first); EXPECT_STREQ(kFakeExtensions, GetExtensions().second); - base::CommandLine command_line(base::CommandLine::NO_PROGRAM); - command_line.AppendSwitchASCII(switches::kDisableGLExtensions, - kFakeDisabledExtensions); - InitializeAPI(&command_line); + InitializeAPI(kFakeDisabledExtensions); EXPECT_STREQ(kFilteredClientExtensions, GetExtensions().first); EXPECT_STREQ(kFilteredExtensions, GetExtensions().second); diff --git a/chromium/ui/gl/extension_set.cc b/chromium/ui/gl/extension_set.cc new file mode 100644 index 00000000000..f1b0154e37b --- /dev/null +++ b/chromium/ui/gl/extension_set.cc @@ -0,0 +1,20 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/gl/extension_set.h" +#include "base/strings/string_split.h" + +namespace gl { + +ExtensionSet MakeExtensionSet(const base::StringPiece& extensions_string) { + return ExtensionSet(SplitStringPiece( + extensions_string, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)); +} + +bool HasExtension(const ExtensionSet& extension_set, + const base::StringPiece& extension) { + return extension_set.find(extension) != extension_set.end(); +} + +} // namespace gl diff --git a/chromium/ui/gl/extension_set.h b/chromium/ui/gl/extension_set.h new file mode 100644 index 00000000000..e8d36227c1a --- /dev/null +++ b/chromium/ui/gl/extension_set.h @@ -0,0 +1,30 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_GL_EXTENSION_SET_H_ +#define UI_GL_EXTENSION_SET_H_ + +#include "base/containers/flat_set.h" +#include "base/strings/string_piece.h" +#include "ui/gl/gl_export.h" + +namespace gl { + +using ExtensionSet = base::flat_set<base::StringPiece>; + +GL_EXPORT ExtensionSet +MakeExtensionSet(const base::StringPiece& extensions_string); + +GL_EXPORT bool HasExtension(const ExtensionSet& extension_set, + const base::StringPiece& extension); + +template <size_t N> +inline bool HasExtension(const ExtensionSet& extension_set, + const char (&extension)[N]) { + return HasExtension(extension_set, base::StringPiece(extension, N - 1)); +} + +} // namespace gl + +#endif // UI_GL_EXTENSION_SET_H_ diff --git a/chromium/ui/gl/generate_bindings.py b/chromium/ui/gl/generate_bindings.py index 5dbc228dbaa..7c20a09eb51 100755 --- a/chromium/ui/gl/generate_bindings.py +++ b/chromium/ui/gl/generate_bindings.py @@ -760,7 +760,8 @@ GL_FUNCTIONS = [ 'arguments': 'GLenum pname, GLsizei bufSize, GLsizei* length, GLint* data', }, { 'return_type': 'void', - 'versions': [{ 'name': 'glGetInternalformativ' }], + 'versions': [{'name': 'glGetInternalformativ', + 'extensions': ['GL_ARB_internalformat_query']}], 'arguments': 'GLenum target, GLenum internalformat, GLenum pname, ' 'GLsizei bufSize, GLint* params', }, { 'return_type': 'void', @@ -770,6 +771,10 @@ GL_FUNCTIONS = [ 'GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, ' 'GLsizei* length, GLint* params', }, { 'return_type': 'void', + 'versions': [{'name': 'glGetMultisamplefv', + 'extensions': ['GL_ARB_texture_multisample']}], + 'arguments': 'GLenum pname, GLuint index, GLfloat* val', }, +{ 'return_type': 'void', 'versions': [{'name': 'glGetMultisamplefvRobustANGLE', 'extensions': ['GL_ANGLE_robust_client_memory']}], 'arguments': @@ -1273,6 +1278,9 @@ GL_FUNCTIONS = [ 'names': ['glPointParameteri'], 'arguments': 'GLenum pname, GLint param', }, { 'return_type': 'void', + 'names': ['glPolygonMode'], + 'arguments': 'GLenum face, GLenum mode', }, +{ 'return_type': 'void', 'names': ['glPolygonOffset'], 'arguments': 'GLfloat factor, GLfloat units', }, { 'return_type': 'void', @@ -1506,6 +1514,14 @@ GL_FUNCTIONS = [ 'names': ['glTestFenceNV'], 'arguments': 'GLuint fence', }, { 'return_type': 'void', + 'names': ['glTexBuffer', 'glTexBufferOES', 'glTexBufferEXT'], + 'arguments': 'GLenum target, GLenum internalformat, GLuint buffer', } , +{ 'return_type': 'void', + 'names': ['glTexBufferRange', 'glTexBufferRangeOES', 'glTexBufferRangeEXT'], + 'arguments': + 'GLenum target, GLenum internalformat, GLuint buffer, ' + 'GLintptr offset, GLsizeiptr size', }, +{ 'return_type': 'void', 'names': ['glTexImage2D'], 'arguments': 'GLenum target, GLint level, GLint internalformat, GLsizei width, ' @@ -1757,7 +1773,7 @@ GL_FUNCTIONS = [ { 'return_type': 'void', 'known_as': 'glVertexAttribDivisorANGLE', 'names': ['glVertexAttribDivisorARB', 'glVertexAttribDivisorANGLE', - 'glVertexAttribDivisor'], + 'glVertexAttribDivisorEXT', 'glVertexAttribDivisor'], 'arguments': 'GLuint index, GLuint divisor', }, { 'return_type': 'void', @@ -1783,7 +1799,7 @@ GL_FUNCTIONS = [ { 'return_type': 'void', 'names': ['glViewport'], 'arguments': 'GLint x, GLint y, GLsizei width, GLsizei height', }, -{ 'return_type': 'GLenum', +{ 'return_type': 'void', 'versions': [{ 'name': 'glWaitSync', 'extensions': ['GL_ARB_sync'] }], 'arguments': @@ -2438,6 +2454,8 @@ def GenerateHeader(file, functions, set_name, #ifndef UI_GL_GL_BINDINGS_AUTOGEN_%(name)s_H_ #define UI_GL_GL_BINDINGS_AUTOGEN_%(name)s_H_ +#include <string> + namespace gl { class GLContext; @@ -2475,6 +2493,9 @@ class GLContext; %(name)sApi(); virtual ~%(name)sApi(); + virtual void SetDisabledExtensions( + const std::string& disabled_extensions) {} + """ % {'name': set_name.upper()}) for func in functions: file.write(' virtual %s %sFn(%s) = 0;\n' % @@ -2703,25 +2724,22 @@ namespace gl { if set_name == 'gl': file.write("""\ -void DriverGL::InitializeDynamicBindings( - const GLVersionInfo* ver, const std::string& context_extensions) { - std::string extensions = context_extensions + " "; - ALLOW_UNUSED_LOCAL(extensions); - +void DriverGL::InitializeDynamicBindings(const GLVersionInfo* ver, + const ExtensionSet& extensions) { """) elif set_name == 'egl': file.write("""\ void DriverEGL::InitializeClientExtensionBindings() { std::string client_extensions(GetClientExtensions()); - client_extensions += " "; - ALLOW_UNUSED_LOCAL(client_extensions); + ExtensionSet extensions(MakeExtensionSet(client_extensions)); + ALLOW_UNUSED_LOCAL(extensions); """) else: file.write("""\ void Driver%s::InitializeExtensionBindings() { - std::string extensions(GetPlatformExtensions()); - extensions += " "; + std::string platform_extensions(GetPlatformExtensions()); + ExtensionSet extensions(MakeExtensionSet(platform_extensions)); ALLOW_UNUSED_LOCAL(extensions); """ % (set_name.upper(),)) @@ -2730,7 +2748,7 @@ void Driver%s::InitializeExtensionBindings() { # Extra space at the end of the extension name is intentional, # it is used as a separator for extension in extensions: - file.write(' ext.b_%s = %s.find("%s ") != std::string::npos;\n' % + file.write(' ext.b_%s = HasExtension(%s, "%s");\n' % (extension, extension_var, extension)) for func in extension_funcs: @@ -2739,7 +2757,7 @@ void Driver%s::InitializeExtensionBindings() { WriteConditionalFuncBinding(file, func) OutputExtensionBindings( - 'client_extensions', + 'extensions', sorted(used_client_extensions), [ f for f in functions if IsClientExtensionFunc(f) ]) @@ -2748,8 +2766,8 @@ void Driver%s::InitializeExtensionBindings() { } void DriverEGL::InitializeExtensionBindings() { - std::string extensions(GetPlatformExtensions()); - extensions += " "; + std::string platform_extensions(GetPlatformExtensions()); + ExtensionSet extensions(MakeExtensionSet(platform_extensions)); ALLOW_UNUSED_LOCAL(extensions); """) @@ -3306,7 +3324,8 @@ def main(argv): parser.add_option('--verify-order', action='store_true') parser.add_option('--generate-dchecks', action='store_true', help='Generates DCHECKs into the logging functions ' - 'asserting no GL errors (useful for debugging)') + 'asserting no GL errors (useful for debugging with ' + '--enable-gpu-service-logging)') parser.add_option('--validate-bindings', action='store_true', help='Generate DCHECKs to validate function bindings ' ' were correctly supplied (useful for debugging)') diff --git a/chromium/ui/gl/gl_angle_util_win.cc b/chromium/ui/gl/gl_angle_util_win.cc index 45e37ab423b..291ba107eee 100644 --- a/chromium/ui/gl/gl_angle_util_win.cc +++ b/chromium/ui/gl/gl_angle_util_win.cc @@ -101,7 +101,7 @@ base::win::ScopedComPtr<IDCompositionDevice2> QueryDirectCompositionDevice( UINT data_size = sizeof(dcomp_device.Get()); HRESULT hr = d3d11_device->GetPrivateData(kDirectCompositionGUID, &data_size, - &dcomp_device); + dcomp_device.GetAddressOf()); if (SUCCEEDED(hr) && dcomp_device) return dcomp_device; diff --git a/chromium/ui/gl/gl_api_unittest.cc b/chromium/ui/gl/gl_api_unittest.cc index f0185c670e1..b57f54f2355 100644 --- a/chromium/ui/gl/gl_api_unittest.cc +++ b/chromium/ui/gl/gl_api_unittest.cc @@ -46,23 +46,28 @@ class GLApiTest : public testing::Test { fake_extension_strings_ = nullptr; } - void InitializeAPI(base::CommandLine* command_line) { + void InitializeAPI(const char* disabled_extensions) { driver_.reset(new DriverGL()); driver_->fn.glGetStringFn = &FakeGetString; driver_->fn.glGetStringiFn = &FakeGetStringi; driver_->fn.glGetIntegervFn = &FakeGetIntegervFn; api_.reset(new RealGLApi()); - if (command_line) - api_->InitializeWithCommandLine(driver_.get(), command_line); - else - api_->Initialize(driver_.get()); - - api_->InitializeFilteredExtensions(); - std::unique_ptr<GLVersionInfo> version = - GetVersionInfoFromContext(api_.get()); - driver_->InitializeDynamicBindings( - version.get(), GetGLExtensionsFromCurrentContext(api_.get())); + if (disabled_extensions) { + api_->SetDisabledExtensions(disabled_extensions); + } + api_->Initialize(driver_.get()); + + std::string extensions_string = + GetGLExtensionsFromCurrentContext(api_.get()); + ExtensionSet extension_set = MakeExtensionSet(extensions_string); + + auto version = std::make_unique<GLVersionInfo>( + reinterpret_cast<const char*>(api_->glGetStringFn(GL_VERSION)), + reinterpret_cast<const char*>(api_->glGetStringFn(GL_RENDERER)), + extension_set); + + driver_->InitializeDynamicBindings(version.get(), extension_set); api_->set_version(std::move(version)); } @@ -135,14 +140,9 @@ TEST_F(GLApiTest, DisabledExtensionStringTest) { SetFakeExtensionString(kFakeExtensions); InitializeAPI(nullptr); - EXPECT_STREQ(kFakeExtensions, GetExtensions()); - base::CommandLine command_line(base::CommandLine::NO_PROGRAM); - command_line.AppendSwitchASCII(switches::kDisableGLExtensions, - kFakeDisabledExtensions); - InitializeAPI(&command_line); - + InitializeAPI(kFakeDisabledExtensions); EXPECT_STREQ(kFilteredExtensions, GetExtensions()); } @@ -154,14 +154,9 @@ TEST_F(GLApiTest, DisabledExtensionBitTest) { SetFakeExtensionStrings(kFakeExtensions, arraysize(kFakeExtensions)); InitializeAPI(nullptr); - EXPECT_TRUE(driver_->ext.b_GL_ARB_timer_query); - base::CommandLine command_line(base::CommandLine::NO_PROGRAM); - command_line.AppendSwitchASCII(switches::kDisableGLExtensions, - kFakeDisabledExtensions); - InitializeAPI(&command_line); - + InitializeAPI(kFakeDisabledExtensions); EXPECT_FALSE(driver_->ext.b_GL_ARB_timer_query); } @@ -186,11 +181,7 @@ TEST_F(GLApiTest, DisabledExtensionStringIndexTest) { EXPECT_STREQ(kFakeExtensions[i], GetExtensioni(i)); } - base::CommandLine command_line(base::CommandLine::NO_PROGRAM); - command_line.AppendSwitchASCII(switches::kDisableGLExtensions, - kFakeDisabledExtensions); - InitializeAPI(&command_line); - + InitializeAPI(kFakeDisabledExtensions); EXPECT_EQ(arraysize(kFilteredExtensions), GetNumExtensions()); for (uint32_t i = 0; i < arraysize(kFilteredExtensions); ++i) { EXPECT_STREQ(kFilteredExtensions[i], GetExtensioni(i)); diff --git a/chromium/ui/gl/gl_bindings.cc b/chromium/ui/gl/gl_bindings.cc index 9e7bcfea0d6..05c45495fa0 100644 --- a/chromium/ui/gl/gl_bindings.cc +++ b/chromium/ui/gl/gl_bindings.cc @@ -47,6 +47,27 @@ std::string DriverEGL::GetPlatformExtensions() { return str ? std::string(str) : ""; } +void DriverEGL::UpdateConditionalExtensionBindings() { + // For the moment, only two extensions can be conditionally disabled + // through GPU driver bug workarounds mechanism: + // EGL_KHR_fence_sync + // EGL_KHR_wait_sync + + // In theory it's OK to allow disabling other EGL extensions, as far as they + // are not the ones used in GLSurfaceEGL::InitializeOneOff(). + + std::string extensions(GetPlatformExtensions()); + extensions += " "; + + ext.b_EGL_KHR_fence_sync = + extensions.find("EGL_KHR_fence_sync ") != std::string::npos; + ext.b_EGL_KHR_wait_sync = + extensions.find("EGL_KHR_wait_sync ") != std::string::npos; + if (!ext.b_EGL_KHR_wait_sync) { + fn.eglWaitSyncKHRFn = nullptr; + } +} + // static std::string DriverEGL::GetClientExtensions() { const char* str = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); diff --git a/chromium/ui/gl/gl_bindings.h b/chromium/ui/gl/gl_bindings.h index f0e7f583c31..df7895eed20 100644 --- a/chromium/ui/gl/gl_bindings.h +++ b/chromium/ui/gl/gl_bindings.h @@ -29,6 +29,7 @@ #include "base/logging.h" #include "base/threading/thread_local.h" #include "build/build_config.h" +#include "ui/gl/extension_set.h" #include "ui/gl/gl_export.h" // The standard OpenGL native extension headers are also included. @@ -163,6 +164,15 @@ #define GL_SUBSCRIBED_VALUES_BUFFER_CHROMIUM 0x924B #define GL_MOUSE_POSITION_CHROMIUM 0x924C +// GL_CHROMIUM_texture_filtering_hint +#define GL_TEXTURE_FILTERING_HINT_CHROMIUM 0x8AF0 + +// GL_CHROMIUM_resize +#define GL_COLOR_SPACE_UNSPECIFIED_CHROMIUM 0x8AF1 +#define GL_COLOR_SPACE_SCRGB_LINEAR_CHROMIUM 0x8AF2 +#define GL_COLOR_SPACE_SRGB_CHROMIUM 0x8AF3 +#define GL_COLOR_SPACE_DISPLAY_P3_CHROMIUM 0x8AF4 + // GL_OES_texure_3D #define GL_SAMPLER_3D_OES 0x8B5F @@ -415,7 +425,7 @@ struct GLVersionInfo; struct GL_EXPORT DriverGL { void InitializeStaticBindings(); void InitializeDynamicBindings(const GLVersionInfo* ver, - const std::string& context_extensions); + const ExtensionSet& extensions); void ClearBindings(); ProcsGL fn; @@ -460,6 +470,7 @@ struct GL_EXPORT DriverEGL { void InitializeClientExtensionBindings(); void InitializeExtensionBindings(); void ClearBindings(); + void UpdateConditionalExtensionBindings(); ProcsEGL fn; ExtensionsEGL ext; diff --git a/chromium/ui/gl/gl_bindings_api_autogen_gl.h b/chromium/ui/gl/gl_bindings_api_autogen_gl.h index 5403786bb53..1df021c8718 100644 --- a/chromium/ui/gl/gl_bindings_api_autogen_gl.h +++ b/chromium/ui/gl/gl_bindings_api_autogen_gl.h @@ -528,6 +528,7 @@ void glGetInternalformativRobustANGLEFn(GLenum target, GLsizei bufSize, GLsizei* length, GLint* params) override; +void glGetMultisamplefvFn(GLenum pname, GLuint index, GLfloat* val) override; void glGetMultisamplefvRobustANGLEFn(GLenum pname, GLuint index, GLsizei bufSize, @@ -861,6 +862,7 @@ void glPathStencilFuncNVFn(GLenum func, GLint ref, GLuint mask) override; void glPauseTransformFeedbackFn(void) override; void glPixelStoreiFn(GLenum pname, GLint param) override; void glPointParameteriFn(GLenum pname, GLint param) override; +void glPolygonModeFn(GLenum face, GLenum mode) override; void glPolygonOffsetFn(GLfloat factor, GLfloat units) override; void glPopDebugGroupFn() override; void glPopGroupMarkerEXTFn(void) override; @@ -1039,6 +1041,14 @@ void glStencilThenCoverStrokePathNVFn(GLuint path, GLenum coverMode) override; GLboolean glTestFenceAPPLEFn(GLuint fence) override; GLboolean glTestFenceNVFn(GLuint fence) override; +void glTexBufferFn(GLenum target, + GLenum internalformat, + GLuint buffer) override; +void glTexBufferRangeFn(GLenum target, + GLenum internalformat, + GLuint buffer, + GLintptr offset, + GLsizeiptr size) override; void glTexImage2DFn(GLenum target, GLint level, GLint internalformat, @@ -1271,4 +1281,4 @@ void glVertexAttribPointerFn(GLuint indx, GLsizei stride, const void* ptr) override; void glViewportFn(GLint x, GLint y, GLsizei width, GLsizei height) override; -GLenum glWaitSyncFn(GLsync sync, GLbitfield flags, GLuint64 timeout) override; +void glWaitSyncFn(GLsync sync, GLbitfield flags, GLuint64 timeout) override; diff --git a/chromium/ui/gl/gl_bindings_autogen_egl.cc b/chromium/ui/gl/gl_bindings_autogen_egl.cc index 637996d7ec3..52c8aafc841 100644 --- a/chromium/ui/gl/gl_bindings_autogen_egl.cc +++ b/chromium/ui/gl/gl_bindings_autogen_egl.cc @@ -128,11 +128,11 @@ void DriverEGL::InitializeStaticBindings() { void DriverEGL::InitializeClientExtensionBindings() { std::string client_extensions(GetClientExtensions()); - client_extensions += " "; - ALLOW_UNUSED_LOCAL(client_extensions); + ExtensionSet extensions(MakeExtensionSet(client_extensions)); + ALLOW_UNUSED_LOCAL(extensions); ext.b_EGL_EXT_platform_base = - client_extensions.find("EGL_EXT_platform_base ") != std::string::npos; + HasExtension(extensions, "EGL_EXT_platform_base"); if (ext.b_EGL_EXT_platform_base) { fn.eglGetPlatformDisplayEXTFn = @@ -142,51 +142,41 @@ void DriverEGL::InitializeClientExtensionBindings() { } void DriverEGL::InitializeExtensionBindings() { - std::string extensions(GetPlatformExtensions()); - extensions += " "; + std::string platform_extensions(GetPlatformExtensions()); + ExtensionSet extensions(MakeExtensionSet(platform_extensions)); ALLOW_UNUSED_LOCAL(extensions); ext.b_EGL_ANGLE_d3d_share_handle_client_buffer = - extensions.find("EGL_ANGLE_d3d_share_handle_client_buffer ") != - std::string::npos; + HasExtension(extensions, "EGL_ANGLE_d3d_share_handle_client_buffer"); ext.b_EGL_ANGLE_program_cache_control = - extensions.find("EGL_ANGLE_program_cache_control ") != std::string::npos; + HasExtension(extensions, "EGL_ANGLE_program_cache_control"); ext.b_EGL_ANGLE_query_surface_pointer = - extensions.find("EGL_ANGLE_query_surface_pointer ") != std::string::npos; + HasExtension(extensions, "EGL_ANGLE_query_surface_pointer"); ext.b_EGL_ANGLE_stream_producer_d3d_texture_nv12 = - extensions.find("EGL_ANGLE_stream_producer_d3d_texture_nv12 ") != - std::string::npos; + HasExtension(extensions, "EGL_ANGLE_stream_producer_d3d_texture_nv12"); ext.b_EGL_ANGLE_surface_d3d_texture_2d_share_handle = - extensions.find("EGL_ANGLE_surface_d3d_texture_2d_share_handle ") != - std::string::npos; + HasExtension(extensions, "EGL_ANGLE_surface_d3d_texture_2d_share_handle"); ext.b_EGL_CHROMIUM_sync_control = - extensions.find("EGL_CHROMIUM_sync_control ") != std::string::npos; + HasExtension(extensions, "EGL_CHROMIUM_sync_control"); ext.b_EGL_EXT_image_flush_external = - extensions.find("EGL_EXT_image_flush_external ") != std::string::npos; - ext.b_EGL_KHR_fence_sync = - extensions.find("EGL_KHR_fence_sync ") != std::string::npos; + HasExtension(extensions, "EGL_EXT_image_flush_external"); + ext.b_EGL_KHR_fence_sync = HasExtension(extensions, "EGL_KHR_fence_sync"); ext.b_EGL_KHR_gl_texture_2D_image = - extensions.find("EGL_KHR_gl_texture_2D_image ") != std::string::npos; - ext.b_EGL_KHR_image = extensions.find("EGL_KHR_image ") != std::string::npos; - ext.b_EGL_KHR_image_base = - extensions.find("EGL_KHR_image_base ") != std::string::npos; - ext.b_EGL_KHR_stream = - extensions.find("EGL_KHR_stream ") != std::string::npos; + HasExtension(extensions, "EGL_KHR_gl_texture_2D_image"); + ext.b_EGL_KHR_image = HasExtension(extensions, "EGL_KHR_image"); + ext.b_EGL_KHR_image_base = HasExtension(extensions, "EGL_KHR_image_base"); + ext.b_EGL_KHR_stream = HasExtension(extensions, "EGL_KHR_stream"); ext.b_EGL_KHR_stream_consumer_gltexture = - extensions.find("EGL_KHR_stream_consumer_gltexture ") != - std::string::npos; + HasExtension(extensions, "EGL_KHR_stream_consumer_gltexture"); ext.b_EGL_KHR_swap_buffers_with_damage = - extensions.find("EGL_KHR_swap_buffers_with_damage ") != std::string::npos; - ext.b_EGL_KHR_wait_sync = - extensions.find("EGL_KHR_wait_sync ") != std::string::npos; + HasExtension(extensions, "EGL_KHR_swap_buffers_with_damage"); + ext.b_EGL_KHR_wait_sync = HasExtension(extensions, "EGL_KHR_wait_sync"); ext.b_EGL_NV_post_sub_buffer = - extensions.find("EGL_NV_post_sub_buffer ") != std::string::npos; + HasExtension(extensions, "EGL_NV_post_sub_buffer"); ext.b_EGL_NV_stream_consumer_gltexture_yuv = - extensions.find("EGL_NV_stream_consumer_gltexture_yuv ") != - std::string::npos; + HasExtension(extensions, "EGL_NV_stream_consumer_gltexture_yuv"); ext.b_GL_CHROMIUM_egl_khr_fence_sync_hack = - extensions.find("GL_CHROMIUM_egl_khr_fence_sync_hack ") != - std::string::npos; + HasExtension(extensions, "GL_CHROMIUM_egl_khr_fence_sync_hack"); if (ext.b_EGL_KHR_image || ext.b_EGL_KHR_image_base || ext.b_EGL_KHR_gl_texture_2D_image) { diff --git a/chromium/ui/gl/gl_bindings_autogen_egl.h b/chromium/ui/gl/gl_bindings_autogen_egl.h index f054e576db0..834d697eb79 100644 --- a/chromium/ui/gl/gl_bindings_autogen_egl.h +++ b/chromium/ui/gl/gl_bindings_autogen_egl.h @@ -11,6 +11,8 @@ #ifndef UI_GL_GL_BINDINGS_AUTOGEN_EGL_H_ #define UI_GL_GL_BINDINGS_AUTOGEN_EGL_H_ +#include <string> + namespace gl { class GLContext; @@ -321,6 +323,8 @@ class GL_EXPORT EGLApi { EGLApi(); virtual ~EGLApi(); + virtual void SetDisabledExtensions(const std::string& disabled_extensions) {} + virtual EGLBoolean eglBindAPIFn(EGLenum api) = 0; virtual EGLBoolean eglBindTexImageFn(EGLDisplay dpy, EGLSurface surface, diff --git a/chromium/ui/gl/gl_bindings_autogen_gl.cc b/chromium/ui/gl/gl_bindings_autogen_gl.cc index 95faee85992..fadb5c0288e 100644 --- a/chromium/ui/gl/gl_bindings_autogen_gl.cc +++ b/chromium/ui/gl/gl_bindings_autogen_gl.cc @@ -237,6 +237,7 @@ void DriverGL::InitializeStaticBindings() { fn.glGetIntegervRobustANGLEFn = 0; fn.glGetInternalformativFn = 0; fn.glGetInternalformativRobustANGLEFn = 0; + fn.glGetMultisamplefvFn = 0; fn.glGetMultisamplefvRobustANGLEFn = 0; fn.glGetnUniformfvRobustANGLEFn = 0; fn.glGetnUniformivRobustANGLEFn = 0; @@ -368,6 +369,7 @@ void DriverGL::InitializeStaticBindings() { fn.glPixelStoreiFn = reinterpret_cast<glPixelStoreiProc>(GetGLProcAddress("glPixelStorei")); fn.glPointParameteriFn = 0; + fn.glPolygonModeFn = 0; fn.glPolygonOffsetFn = reinterpret_cast<glPolygonOffsetProc>( GetGLProcAddress("glPolygonOffset")); fn.glPopDebugGroupFn = 0; @@ -431,6 +433,8 @@ void DriverGL::InitializeStaticBindings() { fn.glStencilThenCoverStrokePathNVFn = 0; fn.glTestFenceAPPLEFn = 0; fn.glTestFenceNVFn = 0; + fn.glTexBufferFn = 0; + fn.glTexBufferRangeFn = 0; fn.glTexImage2DFn = reinterpret_cast<glTexImage2DProc>(GetGLProcAddress("glTexImage2D")); fn.glTexImage2DRobustANGLEFn = 0; @@ -543,140 +547,128 @@ void DriverGL::InitializeStaticBindings() { fn.glWaitSyncFn = 0; } -void DriverGL::InitializeDynamicBindings( - const GLVersionInfo* ver, - const std::string& context_extensions) { - std::string extensions = context_extensions + " "; - ALLOW_UNUSED_LOCAL(extensions); - +void DriverGL::InitializeDynamicBindings(const GLVersionInfo* ver, + const ExtensionSet& extensions) { ext.b_GL_ANGLE_framebuffer_blit = - extensions.find("GL_ANGLE_framebuffer_blit ") != std::string::npos; + HasExtension(extensions, "GL_ANGLE_framebuffer_blit"); ext.b_GL_ANGLE_framebuffer_multisample = - extensions.find("GL_ANGLE_framebuffer_multisample ") != std::string::npos; + HasExtension(extensions, "GL_ANGLE_framebuffer_multisample"); ext.b_GL_ANGLE_instanced_arrays = - extensions.find("GL_ANGLE_instanced_arrays ") != std::string::npos; + HasExtension(extensions, "GL_ANGLE_instanced_arrays"); ext.b_GL_ANGLE_request_extension = - extensions.find("GL_ANGLE_request_extension ") != std::string::npos; + HasExtension(extensions, "GL_ANGLE_request_extension"); ext.b_GL_ANGLE_robust_client_memory = - extensions.find("GL_ANGLE_robust_client_memory ") != std::string::npos; + HasExtension(extensions, "GL_ANGLE_robust_client_memory"); ext.b_GL_ANGLE_translated_shader_source = - extensions.find("GL_ANGLE_translated_shader_source ") != - std::string::npos; - ext.b_GL_APPLE_fence = - extensions.find("GL_APPLE_fence ") != std::string::npos; + HasExtension(extensions, "GL_ANGLE_translated_shader_source"); + ext.b_GL_APPLE_fence = HasExtension(extensions, "GL_APPLE_fence"); ext.b_GL_APPLE_vertex_array_object = - extensions.find("GL_APPLE_vertex_array_object ") != std::string::npos; + HasExtension(extensions, "GL_APPLE_vertex_array_object"); ext.b_GL_ARB_blend_func_extended = - extensions.find("GL_ARB_blend_func_extended ") != std::string::npos; - ext.b_GL_ARB_draw_buffers = - extensions.find("GL_ARB_draw_buffers ") != std::string::npos; + HasExtension(extensions, "GL_ARB_blend_func_extended"); + ext.b_GL_ARB_draw_buffers = HasExtension(extensions, "GL_ARB_draw_buffers"); ext.b_GL_ARB_draw_instanced = - extensions.find("GL_ARB_draw_instanced ") != std::string::npos; + HasExtension(extensions, "GL_ARB_draw_instanced"); ext.b_GL_ARB_get_program_binary = - extensions.find("GL_ARB_get_program_binary ") != std::string::npos; + HasExtension(extensions, "GL_ARB_get_program_binary"); ext.b_GL_ARB_instanced_arrays = - extensions.find("GL_ARB_instanced_arrays ") != std::string::npos; + HasExtension(extensions, "GL_ARB_instanced_arrays"); + ext.b_GL_ARB_internalformat_query = + HasExtension(extensions, "GL_ARB_internalformat_query"); ext.b_GL_ARB_map_buffer_range = - extensions.find("GL_ARB_map_buffer_range ") != std::string::npos; + HasExtension(extensions, "GL_ARB_map_buffer_range"); ext.b_GL_ARB_occlusion_query = - extensions.find("GL_ARB_occlusion_query ") != std::string::npos; + HasExtension(extensions, "GL_ARB_occlusion_query"); ext.b_GL_ARB_program_interface_query = - extensions.find("GL_ARB_program_interface_query ") != std::string::npos; - ext.b_GL_ARB_robustness = - extensions.find("GL_ARB_robustness ") != std::string::npos; + HasExtension(extensions, "GL_ARB_program_interface_query"); + ext.b_GL_ARB_robustness = HasExtension(extensions, "GL_ARB_robustness"); ext.b_GL_ARB_sampler_objects = - extensions.find("GL_ARB_sampler_objects ") != std::string::npos; + HasExtension(extensions, "GL_ARB_sampler_objects"); ext.b_GL_ARB_shader_image_load_store = - extensions.find("GL_ARB_shader_image_load_store ") != std::string::npos; - ext.b_GL_ARB_sync = extensions.find("GL_ARB_sync ") != std::string::npos; + HasExtension(extensions, "GL_ARB_shader_image_load_store"); + ext.b_GL_ARB_sync = HasExtension(extensions, "GL_ARB_sync"); + ext.b_GL_ARB_texture_multisample = + HasExtension(extensions, "GL_ARB_texture_multisample"); ext.b_GL_ARB_texture_storage = - extensions.find("GL_ARB_texture_storage ") != std::string::npos; - ext.b_GL_ARB_timer_query = - extensions.find("GL_ARB_timer_query ") != std::string::npos; + HasExtension(extensions, "GL_ARB_texture_storage"); + ext.b_GL_ARB_timer_query = HasExtension(extensions, "GL_ARB_timer_query"); ext.b_GL_ARB_transform_feedback2 = - extensions.find("GL_ARB_transform_feedback2 ") != std::string::npos; + HasExtension(extensions, "GL_ARB_transform_feedback2"); ext.b_GL_ARB_vertex_array_object = - extensions.find("GL_ARB_vertex_array_object ") != std::string::npos; + HasExtension(extensions, "GL_ARB_vertex_array_object"); ext.b_GL_CHROMIUM_bind_uniform_location = - extensions.find("GL_CHROMIUM_bind_uniform_location ") != - std::string::npos; + HasExtension(extensions, "GL_CHROMIUM_bind_uniform_location"); ext.b_GL_CHROMIUM_compressed_copy_texture = - extensions.find("GL_CHROMIUM_compressed_copy_texture ") != - std::string::npos; + HasExtension(extensions, "GL_CHROMIUM_compressed_copy_texture"); ext.b_GL_CHROMIUM_copy_compressed_texture = - extensions.find("GL_CHROMIUM_copy_compressed_texture ") != - std::string::npos; + HasExtension(extensions, "GL_CHROMIUM_copy_compressed_texture"); ext.b_GL_CHROMIUM_copy_texture = - extensions.find("GL_CHROMIUM_copy_texture ") != std::string::npos; + HasExtension(extensions, "GL_CHROMIUM_copy_texture"); ext.b_GL_CHROMIUM_gles_depth_binding_hack = - extensions.find("GL_CHROMIUM_gles_depth_binding_hack ") != - std::string::npos; + HasExtension(extensions, "GL_CHROMIUM_gles_depth_binding_hack"); ext.b_GL_CHROMIUM_glgetstringi_hack = - extensions.find("GL_CHROMIUM_glgetstringi_hack ") != std::string::npos; + HasExtension(extensions, "GL_CHROMIUM_glgetstringi_hack"); ext.b_GL_EXT_blend_func_extended = - extensions.find("GL_EXT_blend_func_extended ") != std::string::npos; - ext.b_GL_EXT_debug_marker = - extensions.find("GL_EXT_debug_marker ") != std::string::npos; + HasExtension(extensions, "GL_EXT_blend_func_extended"); + ext.b_GL_EXT_debug_marker = HasExtension(extensions, "GL_EXT_debug_marker"); ext.b_GL_EXT_direct_state_access = - extensions.find("GL_EXT_direct_state_access ") != std::string::npos; + HasExtension(extensions, "GL_EXT_direct_state_access"); ext.b_GL_EXT_discard_framebuffer = - extensions.find("GL_EXT_discard_framebuffer ") != std::string::npos; + HasExtension(extensions, "GL_EXT_discard_framebuffer"); ext.b_GL_EXT_disjoint_timer_query = - extensions.find("GL_EXT_disjoint_timer_query ") != std::string::npos; - ext.b_GL_EXT_draw_buffers = - extensions.find("GL_EXT_draw_buffers ") != std::string::npos; + HasExtension(extensions, "GL_EXT_disjoint_timer_query"); + ext.b_GL_EXT_draw_buffers = HasExtension(extensions, "GL_EXT_draw_buffers"); ext.b_GL_EXT_framebuffer_blit = - extensions.find("GL_EXT_framebuffer_blit ") != std::string::npos; + HasExtension(extensions, "GL_EXT_framebuffer_blit"); ext.b_GL_EXT_framebuffer_multisample = - extensions.find("GL_EXT_framebuffer_multisample ") != std::string::npos; + HasExtension(extensions, "GL_EXT_framebuffer_multisample"); ext.b_GL_EXT_framebuffer_object = - extensions.find("GL_EXT_framebuffer_object ") != std::string::npos; - ext.b_GL_EXT_gpu_shader4 = - extensions.find("GL_EXT_gpu_shader4 ") != std::string::npos; + HasExtension(extensions, "GL_EXT_framebuffer_object"); + ext.b_GL_EXT_gpu_shader4 = HasExtension(extensions, "GL_EXT_gpu_shader4"); + ext.b_GL_EXT_instanced_arrays = + HasExtension(extensions, "GL_EXT_instanced_arrays"); ext.b_GL_EXT_map_buffer_range = - extensions.find("GL_EXT_map_buffer_range ") != std::string::npos; + HasExtension(extensions, "GL_EXT_map_buffer_range"); ext.b_GL_EXT_multisampled_render_to_texture = - extensions.find("GL_EXT_multisampled_render_to_texture ") != - std::string::npos; + HasExtension(extensions, "GL_EXT_multisampled_render_to_texture"); ext.b_GL_EXT_occlusion_query_boolean = - extensions.find("GL_EXT_occlusion_query_boolean ") != std::string::npos; - ext.b_GL_EXT_robustness = - extensions.find("GL_EXT_robustness ") != std::string::npos; + HasExtension(extensions, "GL_EXT_occlusion_query_boolean"); + ext.b_GL_EXT_robustness = HasExtension(extensions, "GL_EXT_robustness"); ext.b_GL_EXT_shader_image_load_store = - extensions.find("GL_EXT_shader_image_load_store ") != std::string::npos; + HasExtension(extensions, "GL_EXT_shader_image_load_store"); + ext.b_GL_EXT_texture_buffer = + HasExtension(extensions, "GL_EXT_texture_buffer"); + ext.b_GL_EXT_texture_buffer_object = + HasExtension(extensions, "GL_EXT_texture_buffer_object"); ext.b_GL_EXT_texture_storage = - extensions.find("GL_EXT_texture_storage ") != std::string::npos; - ext.b_GL_EXT_timer_query = - extensions.find("GL_EXT_timer_query ") != std::string::npos; + HasExtension(extensions, "GL_EXT_texture_storage"); + ext.b_GL_EXT_timer_query = HasExtension(extensions, "GL_EXT_timer_query"); ext.b_GL_EXT_transform_feedback = - extensions.find("GL_EXT_transform_feedback ") != std::string::npos; + HasExtension(extensions, "GL_EXT_transform_feedback"); ext.b_GL_EXT_unpack_subimage = - extensions.find("GL_EXT_unpack_subimage ") != std::string::npos; + HasExtension(extensions, "GL_EXT_unpack_subimage"); ext.b_GL_IMG_multisampled_render_to_texture = - extensions.find("GL_IMG_multisampled_render_to_texture ") != - std::string::npos; + HasExtension(extensions, "GL_IMG_multisampled_render_to_texture"); ext.b_GL_INTEL_framebuffer_CMAA = - extensions.find("GL_INTEL_framebuffer_CMAA ") != std::string::npos; + HasExtension(extensions, "GL_INTEL_framebuffer_CMAA"); ext.b_GL_KHR_blend_equation_advanced = - extensions.find("GL_KHR_blend_equation_advanced ") != std::string::npos; - ext.b_GL_KHR_debug = extensions.find("GL_KHR_debug ") != std::string::npos; - ext.b_GL_KHR_robustness = - extensions.find("GL_KHR_robustness ") != std::string::npos; + HasExtension(extensions, "GL_KHR_blend_equation_advanced"); + ext.b_GL_KHR_debug = HasExtension(extensions, "GL_KHR_debug"); + ext.b_GL_KHR_robustness = HasExtension(extensions, "GL_KHR_robustness"); ext.b_GL_NV_blend_equation_advanced = - extensions.find("GL_NV_blend_equation_advanced ") != std::string::npos; - ext.b_GL_NV_fence = extensions.find("GL_NV_fence ") != std::string::npos; + HasExtension(extensions, "GL_NV_blend_equation_advanced"); + ext.b_GL_NV_fence = HasExtension(extensions, "GL_NV_fence"); ext.b_GL_NV_framebuffer_mixed_samples = - extensions.find("GL_NV_framebuffer_mixed_samples ") != std::string::npos; - ext.b_GL_NV_path_rendering = - extensions.find("GL_NV_path_rendering ") != std::string::npos; - ext.b_GL_OES_EGL_image = - extensions.find("GL_OES_EGL_image ") != std::string::npos; + HasExtension(extensions, "GL_NV_framebuffer_mixed_samples"); + ext.b_GL_NV_path_rendering = HasExtension(extensions, "GL_NV_path_rendering"); + ext.b_GL_OES_EGL_image = HasExtension(extensions, "GL_OES_EGL_image"); ext.b_GL_OES_get_program_binary = - extensions.find("GL_OES_get_program_binary ") != std::string::npos; - ext.b_GL_OES_mapbuffer = - extensions.find("GL_OES_mapbuffer ") != std::string::npos; + HasExtension(extensions, "GL_OES_get_program_binary"); + ext.b_GL_OES_mapbuffer = HasExtension(extensions, "GL_OES_mapbuffer"); + ext.b_GL_OES_texture_buffer = + HasExtension(extensions, "GL_OES_texture_buffer"); ext.b_GL_OES_vertex_array_object = - extensions.find("GL_OES_vertex_array_object ") != std::string::npos; + HasExtension(extensions, "GL_OES_vertex_array_object"); if (ext.b_GL_INTEL_framebuffer_CMAA) { fn.glApplyFramebufferAttachmentCMAAINTELFn = @@ -1453,7 +1445,8 @@ void DriverGL::InitializeDynamicBindings( GetGLProcAddress("glGetIntegervRobustANGLE")); } - if (ver->IsAtLeastGL(4u, 2u) || ver->IsAtLeastGLES(3u, 0u)) { + if (ver->IsAtLeastGL(4u, 2u) || ver->IsAtLeastGLES(3u, 0u) || + ext.b_GL_ARB_internalformat_query) { fn.glGetInternalformativFn = reinterpret_cast<glGetInternalformativProc>( GetGLProcAddress("glGetInternalformativ")); } @@ -1464,6 +1457,12 @@ void DriverGL::InitializeDynamicBindings( GetGLProcAddress("glGetInternalformativRobustANGLE")); } + if (ver->IsAtLeastGL(3u, 2u) || ver->IsAtLeastGLES(3u, 1u) || + ext.b_GL_ARB_texture_multisample) { + fn.glGetMultisamplefvFn = reinterpret_cast<glGetMultisamplefvProc>( + GetGLProcAddress("glGetMultisamplefv")); + } + if (ext.b_GL_ANGLE_robust_client_memory) { fn.glGetMultisamplefvRobustANGLEFn = reinterpret_cast<glGetMultisamplefvRobustANGLEProc>( @@ -2020,6 +2019,11 @@ void DriverGL::InitializeDynamicBindings( GetGLProcAddress("glPointParameteri")); } + if (!ver->is_es) { + fn.glPolygonModeFn = + reinterpret_cast<glPolygonModeProc>(GetGLProcAddress("glPolygonMode")); + } + if (ver->IsAtLeastGL(4u, 3u) || ver->IsAtLeastGLES(3u, 2u)) { fn.glPopDebugGroupFn = reinterpret_cast<glPopDebugGroupProc>( GetGLProcAddress("glPopDebugGroup")); @@ -2271,6 +2275,29 @@ void DriverGL::InitializeDynamicBindings( reinterpret_cast<glTestFenceNVProc>(GetGLProcAddress("glTestFenceNV")); } + if (ver->IsAtLeastGLES(3u, 2u) || ver->IsAtLeastGL(3u, 1u)) { + fn.glTexBufferFn = + reinterpret_cast<glTexBufferProc>(GetGLProcAddress("glTexBuffer")); + } else if (ext.b_GL_OES_texture_buffer) { + fn.glTexBufferFn = + reinterpret_cast<glTexBufferProc>(GetGLProcAddress("glTexBufferOES")); + } else if (ext.b_GL_EXT_texture_buffer_object || + ext.b_GL_EXT_texture_buffer) { + fn.glTexBufferFn = + reinterpret_cast<glTexBufferProc>(GetGLProcAddress("glTexBufferEXT")); + } + + if (ver->IsAtLeastGL(4u, 3u) || ver->IsAtLeastGLES(3u, 2u)) { + fn.glTexBufferRangeFn = reinterpret_cast<glTexBufferRangeProc>( + GetGLProcAddress("glTexBufferRange")); + } else if (ext.b_GL_OES_texture_buffer) { + fn.glTexBufferRangeFn = reinterpret_cast<glTexBufferRangeProc>( + GetGLProcAddress("glTexBufferRangeOES")); + } else if (ext.b_GL_EXT_texture_buffer) { + fn.glTexBufferRangeFn = reinterpret_cast<glTexBufferRangeProc>( + GetGLProcAddress("glTexBufferRangeEXT")); + } + if (ext.b_GL_ANGLE_robust_client_memory) { fn.glTexImage2DRobustANGLEFn = reinterpret_cast<glTexImage2DRobustANGLEProc>( @@ -2449,6 +2476,10 @@ void DriverGL::InitializeDynamicBindings( fn.glVertexAttribDivisorANGLEFn = reinterpret_cast<glVertexAttribDivisorANGLEProc>( GetGLProcAddress("glVertexAttribDivisorANGLE")); + } else if (ext.b_GL_EXT_instanced_arrays) { + fn.glVertexAttribDivisorANGLEFn = + reinterpret_cast<glVertexAttribDivisorANGLEProc>( + GetGLProcAddress("glVertexAttribDivisorEXT")); } if (ver->IsAtLeastGL(3u, 0u) || ver->IsAtLeastGLES(3u, 0u)) { @@ -3560,6 +3591,10 @@ void GLApiBase::glGetInternalformativRobustANGLEFn(GLenum target, bufSize, length, params); } +void GLApiBase::glGetMultisamplefvFn(GLenum pname, GLuint index, GLfloat* val) { + driver_->fn.glGetMultisamplefvFn(pname, index, val); +} + void GLApiBase::glGetMultisamplefvRobustANGLEFn(GLenum pname, GLuint index, GLsizei bufSize, @@ -4271,6 +4306,10 @@ void GLApiBase::glPointParameteriFn(GLenum pname, GLint param) { driver_->fn.glPointParameteriFn(pname, param); } +void GLApiBase::glPolygonModeFn(GLenum face, GLenum mode) { + driver_->fn.glPolygonModeFn(face, mode); +} + void GLApiBase::glPolygonOffsetFn(GLfloat factor, GLfloat units) { driver_->fn.glPolygonOffsetFn(factor, units); } @@ -4630,6 +4669,20 @@ GLboolean GLApiBase::glTestFenceNVFn(GLuint fence) { return driver_->fn.glTestFenceNVFn(fence); } +void GLApiBase::glTexBufferFn(GLenum target, + GLenum internalformat, + GLuint buffer) { + driver_->fn.glTexBufferFn(target, internalformat, buffer); +} + +void GLApiBase::glTexBufferRangeFn(GLenum target, + GLenum internalformat, + GLuint buffer, + GLintptr offset, + GLsizeiptr size) { + driver_->fn.glTexBufferRangeFn(target, internalformat, buffer, offset, size); +} + void GLApiBase::glTexImage2DFn(GLenum target, GLint level, GLint internalformat, @@ -5121,10 +5174,8 @@ void GLApiBase::glViewportFn(GLint x, GLint y, GLsizei width, GLsizei height) { driver_->fn.glViewportFn(x, y, width, height); } -GLenum GLApiBase::glWaitSyncFn(GLsync sync, - GLbitfield flags, - GLuint64 timeout) { - return driver_->fn.glWaitSyncFn(sync, flags, timeout); +void GLApiBase::glWaitSyncFn(GLsync sync, GLbitfield flags, GLuint64 timeout) { + driver_->fn.glWaitSyncFn(sync, flags, timeout); } void TraceGLApi::glActiveTextureFn(GLenum texture) { @@ -6390,6 +6441,13 @@ void TraceGLApi::glGetInternalformativRobustANGLEFn(GLenum target, bufSize, length, params); } +void TraceGLApi::glGetMultisamplefvFn(GLenum pname, + GLuint index, + GLfloat* val) { + TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glGetMultisamplefv") + gl_api_->glGetMultisamplefvFn(pname, index, val); +} + void TraceGLApi::glGetMultisamplefvRobustANGLEFn(GLenum pname, GLuint index, GLsizei bufSize, @@ -7231,6 +7289,11 @@ void TraceGLApi::glPointParameteriFn(GLenum pname, GLint param) { gl_api_->glPointParameteriFn(pname, param); } +void TraceGLApi::glPolygonModeFn(GLenum face, GLenum mode) { + TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glPolygonMode") + gl_api_->glPolygonModeFn(face, mode); +} + void TraceGLApi::glPolygonOffsetFn(GLfloat factor, GLfloat units) { TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glPolygonOffset") gl_api_->glPolygonOffsetFn(factor, units); @@ -7655,6 +7718,22 @@ GLboolean TraceGLApi::glTestFenceNVFn(GLuint fence) { return gl_api_->glTestFenceNVFn(fence); } +void TraceGLApi::glTexBufferFn(GLenum target, + GLenum internalformat, + GLuint buffer) { + TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glTexBuffer") + gl_api_->glTexBufferFn(target, internalformat, buffer); +} + +void TraceGLApi::glTexBufferRangeFn(GLenum target, + GLenum internalformat, + GLuint buffer, + GLintptr offset, + GLsizeiptr size) { + TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glTexBufferRange") + gl_api_->glTexBufferRangeFn(target, internalformat, buffer, offset, size); +} + void TraceGLApi::glTexImage2DFn(GLenum target, GLint level, GLint internalformat, @@ -8222,11 +8301,9 @@ void TraceGLApi::glViewportFn(GLint x, GLint y, GLsizei width, GLsizei height) { gl_api_->glViewportFn(x, y, width, height); } -GLenum TraceGLApi::glWaitSyncFn(GLsync sync, - GLbitfield flags, - GLuint64 timeout) { +void TraceGLApi::glWaitSyncFn(GLsync sync, GLbitfield flags, GLuint64 timeout) { TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::glWaitSync") - return gl_api_->glWaitSyncFn(sync, flags, timeout); + gl_api_->glWaitSyncFn(sync, flags, timeout); } void DebugGLApi::glActiveTextureFn(GLenum texture) { @@ -9891,6 +9968,15 @@ void DebugGLApi::glGetInternalformativRobustANGLEFn(GLenum target, bufSize, length, params); } +void DebugGLApi::glGetMultisamplefvFn(GLenum pname, + GLuint index, + GLfloat* val) { + GL_SERVICE_LOG("glGetMultisamplefv" + << "(" << GLEnums::GetStringEnum(pname) << ", " << index + << ", " << static_cast<const void*>(val) << ")"); + gl_api_->glGetMultisamplefvFn(pname, index, val); +} + void DebugGLApi::glGetMultisamplefvRobustANGLEFn(GLenum pname, GLuint index, GLsizei bufSize, @@ -11015,6 +11101,13 @@ void DebugGLApi::glPointParameteriFn(GLenum pname, GLint param) { gl_api_->glPointParameteriFn(pname, param); } +void DebugGLApi::glPolygonModeFn(GLenum face, GLenum mode) { + GL_SERVICE_LOG("glPolygonMode" + << "(" << GLEnums::GetStringEnum(face) << ", " + << GLEnums::GetStringEnum(mode) << ")"); + gl_api_->glPolygonModeFn(face, mode); +} + void DebugGLApi::glPolygonOffsetFn(GLfloat factor, GLfloat units) { GL_SERVICE_LOG("glPolygonOffset" << "(" << factor << ", " << units << ")"); @@ -11581,6 +11674,28 @@ GLboolean DebugGLApi::glTestFenceNVFn(GLuint fence) { return result; } +void DebugGLApi::glTexBufferFn(GLenum target, + GLenum internalformat, + GLuint buffer) { + GL_SERVICE_LOG("glTexBuffer" + << "(" << GLEnums::GetStringEnum(target) << ", " + << GLEnums::GetStringEnum(internalformat) << ", " << buffer + << ")"); + gl_api_->glTexBufferFn(target, internalformat, buffer); +} + +void DebugGLApi::glTexBufferRangeFn(GLenum target, + GLenum internalformat, + GLuint buffer, + GLintptr offset, + GLsizeiptr size) { + GL_SERVICE_LOG("glTexBufferRange" + << "(" << GLEnums::GetStringEnum(target) << ", " + << GLEnums::GetStringEnum(internalformat) << ", " << buffer + << ", " << offset << ", " << size << ")"); + gl_api_->glTexBufferRangeFn(target, internalformat, buffer, offset, size); +} + void DebugGLApi::glTexImage2DFn(GLenum target, GLint level, GLint internalformat, @@ -12325,14 +12440,10 @@ void DebugGLApi::glViewportFn(GLint x, GLint y, GLsizei width, GLsizei height) { gl_api_->glViewportFn(x, y, width, height); } -GLenum DebugGLApi::glWaitSyncFn(GLsync sync, - GLbitfield flags, - GLuint64 timeout) { +void DebugGLApi::glWaitSyncFn(GLsync sync, GLbitfield flags, GLuint64 timeout) { GL_SERVICE_LOG("glWaitSync" << "(" << sync << ", " << flags << ", " << timeout << ")"); - GLenum result = gl_api_->glWaitSyncFn(sync, flags, timeout); - GL_SERVICE_LOG("GL_RESULT: " << result); - return result; + gl_api_->glWaitSyncFn(sync, flags, timeout); } void NoContextGLApi::glActiveTextureFn(GLenum texture) { @@ -13743,6 +13854,15 @@ void NoContextGLApi::glGetInternalformativRobustANGLEFn(GLenum target, "current GL context"; } +void NoContextGLApi::glGetMultisamplefvFn(GLenum pname, + GLuint index, + GLfloat* val) { + NOTREACHED() + << "Trying to call glGetMultisamplefv() without current GL context"; + LOG(ERROR) + << "Trying to call glGetMultisamplefv() without current GL context"; +} + void NoContextGLApi::glGetMultisamplefvRobustANGLEFn(GLenum pname, GLuint index, GLsizei bufSize, @@ -14711,6 +14831,11 @@ void NoContextGLApi::glPointParameteriFn(GLenum pname, GLint param) { LOG(ERROR) << "Trying to call glPointParameteri() without current GL context"; } +void NoContextGLApi::glPolygonModeFn(GLenum face, GLenum mode) { + NOTREACHED() << "Trying to call glPolygonMode() without current GL context"; + LOG(ERROR) << "Trying to call glPolygonMode() without current GL context"; +} + void NoContextGLApi::glPolygonOffsetFn(GLfloat factor, GLfloat units) { NOTREACHED() << "Trying to call glPolygonOffset() without current GL context"; LOG(ERROR) << "Trying to call glPolygonOffset() without current GL context"; @@ -15185,6 +15310,23 @@ GLboolean NoContextGLApi::glTestFenceNVFn(GLuint fence) { return GL_FALSE; } +void NoContextGLApi::glTexBufferFn(GLenum target, + GLenum internalformat, + GLuint buffer) { + NOTREACHED() << "Trying to call glTexBuffer() without current GL context"; + LOG(ERROR) << "Trying to call glTexBuffer() without current GL context"; +} + +void NoContextGLApi::glTexBufferRangeFn(GLenum target, + GLenum internalformat, + GLuint buffer, + GLintptr offset, + GLsizeiptr size) { + NOTREACHED() + << "Trying to call glTexBufferRange() without current GL context"; + LOG(ERROR) << "Trying to call glTexBufferRange() without current GL context"; +} + void NoContextGLApi::glTexImage2DFn(GLenum target, GLint level, GLint internalformat, @@ -15814,12 +15956,11 @@ void NoContextGLApi::glViewportFn(GLint x, LOG(ERROR) << "Trying to call glViewport() without current GL context"; } -GLenum NoContextGLApi::glWaitSyncFn(GLsync sync, - GLbitfield flags, - GLuint64 timeout) { +void NoContextGLApi::glWaitSyncFn(GLsync sync, + GLbitfield flags, + GLuint64 timeout) { NOTREACHED() << "Trying to call glWaitSync() without current GL context"; LOG(ERROR) << "Trying to call glWaitSync() without current GL context"; - return static_cast<GLenum>(0); } } // namespace gl diff --git a/chromium/ui/gl/gl_bindings_autogen_gl.h b/chromium/ui/gl/gl_bindings_autogen_gl.h index db088a34b09..816a0c5dda1 100644 --- a/chromium/ui/gl/gl_bindings_autogen_gl.h +++ b/chromium/ui/gl/gl_bindings_autogen_gl.h @@ -11,6 +11,8 @@ #ifndef UI_GL_GL_BINDINGS_AUTOGEN_GL_H_ #define UI_GL_GL_BINDINGS_AUTOGEN_GL_H_ +#include <string> + namespace gl { class GLContext; @@ -611,6 +613,9 @@ typedef void(GL_BINDING_CALL* glGetInternalformativRobustANGLEProc)( GLsizei bufSize, GLsizei* length, GLint* params); +typedef void(GL_BINDING_CALL* glGetMultisamplefvProc)(GLenum pname, + GLuint index, + GLfloat* val); typedef void(GL_BINDING_CALL* glGetMultisamplefvRobustANGLEProc)( GLenum pname, GLuint index, @@ -1014,6 +1019,7 @@ typedef void(GL_BINDING_CALL* glPathStencilFuncNVProc)(GLenum func, typedef void(GL_BINDING_CALL* glPauseTransformFeedbackProc)(void); typedef void(GL_BINDING_CALL* glPixelStoreiProc)(GLenum pname, GLint param); typedef void(GL_BINDING_CALL* glPointParameteriProc)(GLenum pname, GLint param); +typedef void(GL_BINDING_CALL* glPolygonModeProc)(GLenum face, GLenum mode); typedef void(GL_BINDING_CALL* glPolygonOffsetProc)(GLfloat factor, GLfloat units); typedef void(GL_BINDING_CALL* glPopDebugGroupProc)(); @@ -1223,6 +1229,14 @@ typedef void(GL_BINDING_CALL* glStencilThenCoverStrokePathNVProc)( GLenum coverMode); typedef GLboolean(GL_BINDING_CALL* glTestFenceAPPLEProc)(GLuint fence); typedef GLboolean(GL_BINDING_CALL* glTestFenceNVProc)(GLuint fence); +typedef void(GL_BINDING_CALL* glTexBufferProc)(GLenum target, + GLenum internalformat, + GLuint buffer); +typedef void(GL_BINDING_CALL* glTexBufferRangeProc)(GLenum target, + GLenum internalformat, + GLuint buffer, + GLintptr offset, + GLsizeiptr size); typedef void(GL_BINDING_CALL* glTexImage2DProc)(GLenum target, GLint level, GLint internalformat, @@ -1525,9 +1539,9 @@ typedef void(GL_BINDING_CALL* glViewportProc)(GLint x, GLint y, GLsizei width, GLsizei height); -typedef GLenum(GL_BINDING_CALL* glWaitSyncProc)(GLsync sync, - GLbitfield flags, - GLuint64 timeout); +typedef void(GL_BINDING_CALL* glWaitSyncProc)(GLsync sync, + GLbitfield flags, + GLuint64 timeout); struct ExtensionsGL { bool b_GL_ANGLE_framebuffer_blit; @@ -1543,6 +1557,7 @@ struct ExtensionsGL { bool b_GL_ARB_draw_instanced; bool b_GL_ARB_get_program_binary; bool b_GL_ARB_instanced_arrays; + bool b_GL_ARB_internalformat_query; bool b_GL_ARB_map_buffer_range; bool b_GL_ARB_occlusion_query; bool b_GL_ARB_program_interface_query; @@ -1550,6 +1565,7 @@ struct ExtensionsGL { bool b_GL_ARB_sampler_objects; bool b_GL_ARB_shader_image_load_store; bool b_GL_ARB_sync; + bool b_GL_ARB_texture_multisample; bool b_GL_ARB_texture_storage; bool b_GL_ARB_timer_query; bool b_GL_ARB_transform_feedback2; @@ -1570,11 +1586,14 @@ struct ExtensionsGL { bool b_GL_EXT_framebuffer_multisample; bool b_GL_EXT_framebuffer_object; bool b_GL_EXT_gpu_shader4; + bool b_GL_EXT_instanced_arrays; bool b_GL_EXT_map_buffer_range; bool b_GL_EXT_multisampled_render_to_texture; bool b_GL_EXT_occlusion_query_boolean; bool b_GL_EXT_robustness; bool b_GL_EXT_shader_image_load_store; + bool b_GL_EXT_texture_buffer; + bool b_GL_EXT_texture_buffer_object; bool b_GL_EXT_texture_storage; bool b_GL_EXT_timer_query; bool b_GL_EXT_transform_feedback; @@ -1591,6 +1610,7 @@ struct ExtensionsGL { bool b_GL_OES_EGL_image; bool b_GL_OES_get_program_binary; bool b_GL_OES_mapbuffer; + bool b_GL_OES_texture_buffer; bool b_GL_OES_vertex_array_object; }; @@ -1769,6 +1789,7 @@ struct ProcsGL { glGetIntegervRobustANGLEProc glGetIntegervRobustANGLEFn; glGetInternalformativProc glGetInternalformativFn; glGetInternalformativRobustANGLEProc glGetInternalformativRobustANGLEFn; + glGetMultisamplefvProc glGetMultisamplefvFn; glGetMultisamplefvRobustANGLEProc glGetMultisamplefvRobustANGLEFn; glGetnUniformfvRobustANGLEProc glGetnUniformfvRobustANGLEFn; glGetnUniformivRobustANGLEProc glGetnUniformivRobustANGLEFn; @@ -1879,6 +1900,7 @@ struct ProcsGL { glPauseTransformFeedbackProc glPauseTransformFeedbackFn; glPixelStoreiProc glPixelStoreiFn; glPointParameteriProc glPointParameteriFn; + glPolygonModeProc glPolygonModeFn; glPolygonOffsetProc glPolygonOffsetFn; glPopDebugGroupProc glPopDebugGroupFn; glPopGroupMarkerEXTProc glPopGroupMarkerEXTFn; @@ -1934,6 +1956,8 @@ struct ProcsGL { glStencilThenCoverStrokePathNVProc glStencilThenCoverStrokePathNVFn; glTestFenceAPPLEProc glTestFenceAPPLEFn; glTestFenceNVProc glTestFenceNVFn; + glTexBufferProc glTexBufferFn; + glTexBufferRangeProc glTexBufferRangeFn; glTexImage2DProc glTexImage2DFn; glTexImage2DRobustANGLEProc glTexImage2DRobustANGLEFn; glTexImage3DProc glTexImage3DFn; @@ -2014,6 +2038,8 @@ class GL_EXPORT GLApi { GLApi(); virtual ~GLApi(); + virtual void SetDisabledExtensions(const std::string& disabled_extensions) {} + virtual void glActiveTextureFn(GLenum texture) = 0; virtual void glApplyFramebufferAttachmentCMAAINTELFn(void) = 0; virtual void glAttachShaderFn(GLuint program, GLuint shader) = 0; @@ -2543,6 +2569,9 @@ class GL_EXPORT GLApi { GLsizei bufSize, GLsizei* length, GLint* params) = 0; + virtual void glGetMultisamplefvFn(GLenum pname, + GLuint index, + GLfloat* val) = 0; virtual void glGetMultisamplefvRobustANGLEFn(GLenum pname, GLuint index, GLsizei bufSize, @@ -2896,6 +2925,7 @@ class GL_EXPORT GLApi { virtual void glPauseTransformFeedbackFn(void) = 0; virtual void glPixelStoreiFn(GLenum pname, GLint param) = 0; virtual void glPointParameteriFn(GLenum pname, GLint param) = 0; + virtual void glPolygonModeFn(GLenum face, GLenum mode) = 0; virtual void glPolygonOffsetFn(GLfloat factor, GLfloat units) = 0; virtual void glPopDebugGroupFn() = 0; virtual void glPopGroupMarkerEXTFn(void) = 0; @@ -3082,6 +3112,14 @@ class GL_EXPORT GLApi { GLenum coverMode) = 0; virtual GLboolean glTestFenceAPPLEFn(GLuint fence) = 0; virtual GLboolean glTestFenceNVFn(GLuint fence) = 0; + virtual void glTexBufferFn(GLenum target, + GLenum internalformat, + GLuint buffer) = 0; + virtual void glTexBufferRangeFn(GLenum target, + GLenum internalformat, + GLuint buffer, + GLintptr offset, + GLsizeiptr size) = 0; virtual void glTexImage2DFn(GLenum target, GLint level, GLint internalformat, @@ -3356,9 +3394,9 @@ class GL_EXPORT GLApi { GLint y, GLsizei width, GLsizei height) = 0; - virtual GLenum glWaitSyncFn(GLsync sync, - GLbitfield flags, - GLuint64 timeout) = 0; + virtual void glWaitSyncFn(GLsync sync, + GLbitfield flags, + GLuint64 timeout) = 0; }; } // namespace gl @@ -3596,6 +3634,7 @@ class GL_EXPORT GLApi { ::gl::g_current_gl_context->glGetInternalformativFn #define glGetInternalformativRobustANGLE \ ::gl::g_current_gl_context->glGetInternalformativRobustANGLEFn +#define glGetMultisamplefv ::gl::g_current_gl_context->glGetMultisamplefvFn #define glGetMultisamplefvRobustANGLE \ ::gl::g_current_gl_context->glGetMultisamplefvRobustANGLEFn #define glGetnUniformfvRobustANGLE \ @@ -3756,6 +3795,7 @@ class GL_EXPORT GLApi { ::gl::g_current_gl_context->glPauseTransformFeedbackFn #define glPixelStorei ::gl::g_current_gl_context->glPixelStoreiFn #define glPointParameteri ::gl::g_current_gl_context->glPointParameteriFn +#define glPolygonMode ::gl::g_current_gl_context->glPolygonModeFn #define glPolygonOffset ::gl::g_current_gl_context->glPolygonOffsetFn #define glPopDebugGroup ::gl::g_current_gl_context->glPopDebugGroupFn #define glPopGroupMarkerEXT ::gl::g_current_gl_context->glPopGroupMarkerEXTFn @@ -3833,6 +3873,8 @@ class GL_EXPORT GLApi { ::gl::g_current_gl_context->glStencilThenCoverStrokePathNVFn #define glTestFenceAPPLE ::gl::g_current_gl_context->glTestFenceAPPLEFn #define glTestFenceNV ::gl::g_current_gl_context->glTestFenceNVFn +#define glTexBuffer ::gl::g_current_gl_context->glTexBufferFn +#define glTexBufferRange ::gl::g_current_gl_context->glTexBufferRangeFn #define glTexImage2D ::gl::g_current_gl_context->glTexImage2DFn #define glTexImage2DRobustANGLE \ ::gl::g_current_gl_context->glTexImage2DRobustANGLEFn diff --git a/chromium/ui/gl/gl_bindings_autogen_glx.cc b/chromium/ui/gl/gl_bindings_autogen_glx.cc index ef9f9ef9152..ed79f1dd778 100644 --- a/chromium/ui/gl/gl_bindings_autogen_glx.cc +++ b/chromium/ui/gl/gl_bindings_autogen_glx.cc @@ -114,26 +114,22 @@ void DriverGLX::InitializeStaticBindings() { } void DriverGLX::InitializeExtensionBindings() { - std::string extensions(GetPlatformExtensions()); - extensions += " "; + std::string platform_extensions(GetPlatformExtensions()); + ExtensionSet extensions(MakeExtensionSet(platform_extensions)); ALLOW_UNUSED_LOCAL(extensions); ext.b_GLX_ARB_create_context = - extensions.find("GLX_ARB_create_context ") != std::string::npos; - ext.b_GLX_EXT_swap_control = - extensions.find("GLX_EXT_swap_control ") != std::string::npos; + HasExtension(extensions, "GLX_ARB_create_context"); + ext.b_GLX_EXT_swap_control = HasExtension(extensions, "GLX_EXT_swap_control"); ext.b_GLX_EXT_texture_from_pixmap = - extensions.find("GLX_EXT_texture_from_pixmap ") != std::string::npos; + HasExtension(extensions, "GLX_EXT_texture_from_pixmap"); ext.b_GLX_MESA_copy_sub_buffer = - extensions.find("GLX_MESA_copy_sub_buffer ") != std::string::npos; + HasExtension(extensions, "GLX_MESA_copy_sub_buffer"); ext.b_GLX_MESA_swap_control = - extensions.find("GLX_MESA_swap_control ") != std::string::npos; - ext.b_GLX_OML_sync_control = - extensions.find("GLX_OML_sync_control ") != std::string::npos; - ext.b_GLX_SGIX_fbconfig = - extensions.find("GLX_SGIX_fbconfig ") != std::string::npos; - ext.b_GLX_SGI_video_sync = - extensions.find("GLX_SGI_video_sync ") != std::string::npos; + HasExtension(extensions, "GLX_MESA_swap_control"); + ext.b_GLX_OML_sync_control = HasExtension(extensions, "GLX_OML_sync_control"); + ext.b_GLX_SGIX_fbconfig = HasExtension(extensions, "GLX_SGIX_fbconfig"); + ext.b_GLX_SGI_video_sync = HasExtension(extensions, "GLX_SGI_video_sync"); if (ext.b_GLX_EXT_texture_from_pixmap) { fn.glXBindTexImageEXTFn = reinterpret_cast<glXBindTexImageEXTProc>( diff --git a/chromium/ui/gl/gl_bindings_autogen_glx.h b/chromium/ui/gl/gl_bindings_autogen_glx.h index 2f75778150d..2cd87ed127d 100644 --- a/chromium/ui/gl/gl_bindings_autogen_glx.h +++ b/chromium/ui/gl/gl_bindings_autogen_glx.h @@ -11,6 +11,8 @@ #ifndef UI_GL_GL_BINDINGS_AUTOGEN_GLX_H_ #define UI_GL_GL_BINDINGS_AUTOGEN_GLX_H_ +#include <string> + namespace gl { class GLContext; @@ -229,6 +231,8 @@ class GL_EXPORT GLXApi { GLXApi(); virtual ~GLXApi(); + virtual void SetDisabledExtensions(const std::string& disabled_extensions) {} + virtual void glXBindTexImageEXTFn(Display* dpy, GLXDrawable drawable, int buffer, diff --git a/chromium/ui/gl/gl_bindings_autogen_mock.cc b/chromium/ui/gl/gl_bindings_autogen_mock.cc index 616ac6918c8..812f9103eac 100644 --- a/chromium/ui/gl/gl_bindings_autogen_mock.cc +++ b/chromium/ui/gl/gl_bindings_autogen_mock.cc @@ -1715,6 +1715,13 @@ MockGLInterface::Mock_glGetInternalformativRobustANGLE(GLenum target, bufSize, length, params); } +void GL_BINDING_CALL MockGLInterface::Mock_glGetMultisamplefv(GLenum pname, + GLuint index, + GLfloat* val) { + MakeFunctionUnique("glGetMultisamplefv"); + interface_->GetMultisamplefv(pname, index, val); +} + void GL_BINDING_CALL MockGLInterface::Mock_glGetMultisamplefvRobustANGLE(GLenum pname, GLuint index, @@ -2797,6 +2804,12 @@ void GL_BINDING_CALL MockGLInterface::Mock_glPointParameteri(GLenum pname, interface_->PointParameteri(pname, param); } +void GL_BINDING_CALL MockGLInterface::Mock_glPolygonMode(GLenum face, + GLenum mode) { + MakeFunctionUnique("glPolygonMode"); + interface_->PolygonMode(face, mode); +} + void GL_BINDING_CALL MockGLInterface::Mock_glPolygonOffset(GLfloat factor, GLfloat units) { MakeFunctionUnique("glPolygonOffset"); @@ -3281,6 +3294,57 @@ GLboolean GL_BINDING_CALL MockGLInterface::Mock_glTestFenceNV(GLuint fence) { return interface_->TestFenceNV(fence); } +void GL_BINDING_CALL MockGLInterface::Mock_glTexBuffer(GLenum target, + GLenum internalformat, + GLuint buffer) { + MakeFunctionUnique("glTexBuffer"); + interface_->TexBuffer(target, internalformat, buffer); +} + +void GL_BINDING_CALL MockGLInterface::Mock_glTexBufferEXT(GLenum target, + GLenum internalformat, + GLuint buffer) { + MakeFunctionUnique("glTexBufferEXT"); + interface_->TexBuffer(target, internalformat, buffer); +} + +void GL_BINDING_CALL MockGLInterface::Mock_glTexBufferOES(GLenum target, + GLenum internalformat, + GLuint buffer) { + MakeFunctionUnique("glTexBufferOES"); + interface_->TexBuffer(target, internalformat, buffer); +} + +void GL_BINDING_CALL +MockGLInterface::Mock_glTexBufferRange(GLenum target, + GLenum internalformat, + GLuint buffer, + GLintptr offset, + GLsizeiptr size) { + MakeFunctionUnique("glTexBufferRange"); + interface_->TexBufferRange(target, internalformat, buffer, offset, size); +} + +void GL_BINDING_CALL +MockGLInterface::Mock_glTexBufferRangeEXT(GLenum target, + GLenum internalformat, + GLuint buffer, + GLintptr offset, + GLsizeiptr size) { + MakeFunctionUnique("glTexBufferRangeEXT"); + interface_->TexBufferRange(target, internalformat, buffer, offset, size); +} + +void GL_BINDING_CALL +MockGLInterface::Mock_glTexBufferRangeOES(GLenum target, + GLenum internalformat, + GLuint buffer, + GLintptr offset, + GLsizeiptr size) { + MakeFunctionUnique("glTexBufferRangeOES"); + interface_->TexBufferRange(target, internalformat, buffer, offset, size); +} + void GL_BINDING_CALL MockGLInterface::Mock_glTexImage2D(GLenum target, GLint level, GLint internalformat, @@ -3881,6 +3945,12 @@ MockGLInterface::Mock_glVertexAttribDivisorARB(GLuint index, GLuint divisor) { interface_->VertexAttribDivisorANGLE(index, divisor); } +void GL_BINDING_CALL +MockGLInterface::Mock_glVertexAttribDivisorEXT(GLuint index, GLuint divisor) { + MakeFunctionUnique("glVertexAttribDivisorEXT"); + interface_->VertexAttribDivisorANGLE(index, divisor); +} + void GL_BINDING_CALL MockGLInterface::Mock_glVertexAttribI4i(GLuint indx, GLint x, GLint y, @@ -3940,11 +4010,11 @@ void GL_BINDING_CALL MockGLInterface::Mock_glViewport(GLint x, interface_->Viewport(x, y, width, height); } -GLenum GL_BINDING_CALL MockGLInterface::Mock_glWaitSync(GLsync sync, - GLbitfield flags, - GLuint64 timeout) { +void GL_BINDING_CALL MockGLInterface::Mock_glWaitSync(GLsync sync, + GLbitfield flags, + GLuint64 timeout) { MakeFunctionUnique("glWaitSync"); - return interface_->WaitSync(sync, flags, timeout); + interface_->WaitSync(sync, flags, timeout); } static void MockInvalidFunction() { @@ -4445,6 +4515,8 @@ MockGLInterface::GetGLProcAddress(const char* name) { if (strcmp(name, "glGetInternalformativRobustANGLE") == 0) return reinterpret_cast<GLFunctionPointerType>( Mock_glGetInternalformativRobustANGLE); + if (strcmp(name, "glGetMultisamplefv") == 0) + return reinterpret_cast<GLFunctionPointerType>(Mock_glGetMultisamplefv); if (strcmp(name, "glGetMultisamplefvRobustANGLE") == 0) return reinterpret_cast<GLFunctionPointerType>( Mock_glGetMultisamplefvRobustANGLE); @@ -4761,6 +4833,8 @@ MockGLInterface::GetGLProcAddress(const char* name) { return reinterpret_cast<GLFunctionPointerType>(Mock_glPixelStorei); if (strcmp(name, "glPointParameteri") == 0) return reinterpret_cast<GLFunctionPointerType>(Mock_glPointParameteri); + if (strcmp(name, "glPolygonMode") == 0) + return reinterpret_cast<GLFunctionPointerType>(Mock_glPolygonMode); if (strcmp(name, "glPolygonOffset") == 0) return reinterpret_cast<GLFunctionPointerType>(Mock_glPolygonOffset); if (strcmp(name, "glPopDebugGroup") == 0) @@ -4897,6 +4971,18 @@ MockGLInterface::GetGLProcAddress(const char* name) { return reinterpret_cast<GLFunctionPointerType>(Mock_glTestFenceAPPLE); if (strcmp(name, "glTestFenceNV") == 0) return reinterpret_cast<GLFunctionPointerType>(Mock_glTestFenceNV); + if (strcmp(name, "glTexBuffer") == 0) + return reinterpret_cast<GLFunctionPointerType>(Mock_glTexBuffer); + if (strcmp(name, "glTexBufferEXT") == 0) + return reinterpret_cast<GLFunctionPointerType>(Mock_glTexBufferEXT); + if (strcmp(name, "glTexBufferOES") == 0) + return reinterpret_cast<GLFunctionPointerType>(Mock_glTexBufferOES); + if (strcmp(name, "glTexBufferRange") == 0) + return reinterpret_cast<GLFunctionPointerType>(Mock_glTexBufferRange); + if (strcmp(name, "glTexBufferRangeEXT") == 0) + return reinterpret_cast<GLFunctionPointerType>(Mock_glTexBufferRangeEXT); + if (strcmp(name, "glTexBufferRangeOES") == 0) + return reinterpret_cast<GLFunctionPointerType>(Mock_glTexBufferRangeOES); if (strcmp(name, "glTexImage2D") == 0) return reinterpret_cast<GLFunctionPointerType>(Mock_glTexImage2D); if (strcmp(name, "glTexImage2DRobustANGLE") == 0) @@ -5049,6 +5135,9 @@ MockGLInterface::GetGLProcAddress(const char* name) { if (strcmp(name, "glVertexAttribDivisorARB") == 0) return reinterpret_cast<GLFunctionPointerType>( Mock_glVertexAttribDivisorARB); + if (strcmp(name, "glVertexAttribDivisorEXT") == 0) + return reinterpret_cast<GLFunctionPointerType>( + Mock_glVertexAttribDivisorEXT); if (strcmp(name, "glVertexAttribI4i") == 0) return reinterpret_cast<GLFunctionPointerType>(Mock_glVertexAttribI4i); if (strcmp(name, "glVertexAttribI4iv") == 0) diff --git a/chromium/ui/gl/gl_bindings_autogen_mock.h b/chromium/ui/gl/gl_bindings_autogen_mock.h index 89ca6cd59de..6a2e2c6873d 100644 --- a/chromium/ui/gl/gl_bindings_autogen_mock.h +++ b/chromium/ui/gl/gl_bindings_autogen_mock.h @@ -710,6 +710,9 @@ Mock_glGetInternalformativRobustANGLE(GLenum target, GLsizei bufSize, GLsizei* length, GLint* params); +static void GL_BINDING_CALL Mock_glGetMultisamplefv(GLenum pname, + GLuint index, + GLfloat* val); static void GL_BINDING_CALL Mock_glGetMultisamplefvRobustANGLE(GLenum pname, GLuint index, GLsizei bufSize, @@ -1172,6 +1175,7 @@ static void GL_BINDING_CALL Mock_glPathStencilFuncNV(GLenum func, static void GL_BINDING_CALL Mock_glPauseTransformFeedback(void); static void GL_BINDING_CALL Mock_glPixelStorei(GLenum pname, GLint param); static void GL_BINDING_CALL Mock_glPointParameteri(GLenum pname, GLint param); +static void GL_BINDING_CALL Mock_glPolygonMode(GLenum face, GLenum mode); static void GL_BINDING_CALL Mock_glPolygonOffset(GLfloat factor, GLfloat units); static void GL_BINDING_CALL Mock_glPopDebugGroup(); static void GL_BINDING_CALL Mock_glPopDebugGroupKHR(); @@ -1392,6 +1396,30 @@ Mock_glStencilThenCoverStrokePathNV(GLuint path, GLenum coverMode); static GLboolean GL_BINDING_CALL Mock_glTestFenceAPPLE(GLuint fence); static GLboolean GL_BINDING_CALL Mock_glTestFenceNV(GLuint fence); +static void GL_BINDING_CALL Mock_glTexBuffer(GLenum target, + GLenum internalformat, + GLuint buffer); +static void GL_BINDING_CALL Mock_glTexBufferEXT(GLenum target, + GLenum internalformat, + GLuint buffer); +static void GL_BINDING_CALL Mock_glTexBufferOES(GLenum target, + GLenum internalformat, + GLuint buffer); +static void GL_BINDING_CALL Mock_glTexBufferRange(GLenum target, + GLenum internalformat, + GLuint buffer, + GLintptr offset, + GLsizeiptr size); +static void GL_BINDING_CALL Mock_glTexBufferRangeEXT(GLenum target, + GLenum internalformat, + GLuint buffer, + GLintptr offset, + GLsizeiptr size); +static void GL_BINDING_CALL Mock_glTexBufferRangeOES(GLenum target, + GLenum internalformat, + GLuint buffer, + GLintptr offset, + GLsizeiptr size); static void GL_BINDING_CALL Mock_glTexImage2D(GLenum target, GLint level, GLint internalformat, @@ -1664,6 +1692,8 @@ static void GL_BINDING_CALL Mock_glVertexAttribDivisorANGLE(GLuint index, GLuint divisor); static void GL_BINDING_CALL Mock_glVertexAttribDivisorARB(GLuint index, GLuint divisor); +static void GL_BINDING_CALL Mock_glVertexAttribDivisorEXT(GLuint index, + GLuint divisor); static void GL_BINDING_CALL Mock_glVertexAttribI4i(GLuint indx, GLint x, GLint y, GLint z, GLint w); static void GL_BINDING_CALL Mock_glVertexAttribI4iv(GLuint indx, @@ -1687,6 +1717,6 @@ static void GL_BINDING_CALL Mock_glViewport(GLint x, GLint y, GLsizei width, GLsizei height); -static GLenum GL_BINDING_CALL Mock_glWaitSync(GLsync sync, - GLbitfield flags, - GLuint64 timeout); +static void GL_BINDING_CALL Mock_glWaitSync(GLsync sync, + GLbitfield flags, + GLuint64 timeout); diff --git a/chromium/ui/gl/gl_bindings_autogen_osmesa.cc b/chromium/ui/gl/gl_bindings_autogen_osmesa.cc index 27185e32f95..c629e834820 100644 --- a/chromium/ui/gl/gl_bindings_autogen_osmesa.cc +++ b/chromium/ui/gl/gl_bindings_autogen_osmesa.cc @@ -48,8 +48,8 @@ void DriverOSMESA::InitializeStaticBindings() { } void DriverOSMESA::InitializeExtensionBindings() { - std::string extensions(GetPlatformExtensions()); - extensions += " "; + std::string platform_extensions(GetPlatformExtensions()); + ExtensionSet extensions(MakeExtensionSet(platform_extensions)); ALLOW_UNUSED_LOCAL(extensions); } diff --git a/chromium/ui/gl/gl_bindings_autogen_osmesa.h b/chromium/ui/gl/gl_bindings_autogen_osmesa.h index a40bf7875bb..baa9587bc56 100644 --- a/chromium/ui/gl/gl_bindings_autogen_osmesa.h +++ b/chromium/ui/gl/gl_bindings_autogen_osmesa.h @@ -11,6 +11,8 @@ #ifndef UI_GL_GL_BINDINGS_AUTOGEN_OSMESA_H_ #define UI_GL_GL_BINDINGS_AUTOGEN_OSMESA_H_ +#include <string> + namespace gl { class GLContext; @@ -69,6 +71,8 @@ class GL_EXPORT OSMESAApi { OSMESAApi(); virtual ~OSMESAApi(); + virtual void SetDisabledExtensions(const std::string& disabled_extensions) {} + virtual void OSMesaColorClampFn(GLboolean enable) = 0; virtual OSMesaContext OSMesaCreateContextFn(GLenum format, OSMesaContext sharelist) = 0; diff --git a/chromium/ui/gl/gl_bindings_autogen_wgl.cc b/chromium/ui/gl/gl_bindings_autogen_wgl.cc index 465f13a2986..d6bdc1ea004 100644 --- a/chromium/ui/gl/gl_bindings_autogen_wgl.cc +++ b/chromium/ui/gl/gl_bindings_autogen_wgl.cc @@ -58,22 +58,19 @@ void DriverWGL::InitializeStaticBindings() { } void DriverWGL::InitializeExtensionBindings() { - std::string extensions(GetPlatformExtensions()); - extensions += " "; + std::string platform_extensions(GetPlatformExtensions()); + ExtensionSet extensions(MakeExtensionSet(platform_extensions)); ALLOW_UNUSED_LOCAL(extensions); ext.b_WGL_ARB_create_context = - extensions.find("WGL_ARB_create_context ") != std::string::npos; + HasExtension(extensions, "WGL_ARB_create_context"); ext.b_WGL_ARB_extensions_string = - extensions.find("WGL_ARB_extensions_string ") != std::string::npos; - ext.b_WGL_ARB_pbuffer = - extensions.find("WGL_ARB_pbuffer ") != std::string::npos; - ext.b_WGL_ARB_pixel_format = - extensions.find("WGL_ARB_pixel_format ") != std::string::npos; + HasExtension(extensions, "WGL_ARB_extensions_string"); + ext.b_WGL_ARB_pbuffer = HasExtension(extensions, "WGL_ARB_pbuffer"); + ext.b_WGL_ARB_pixel_format = HasExtension(extensions, "WGL_ARB_pixel_format"); ext.b_WGL_EXT_extensions_string = - extensions.find("WGL_EXT_extensions_string ") != std::string::npos; - ext.b_WGL_EXT_swap_control = - extensions.find("WGL_EXT_swap_control ") != std::string::npos; + HasExtension(extensions, "WGL_EXT_extensions_string"); + ext.b_WGL_EXT_swap_control = HasExtension(extensions, "WGL_EXT_swap_control"); if (ext.b_WGL_ARB_pixel_format) { fn.wglChoosePixelFormatARBFn = diff --git a/chromium/ui/gl/gl_bindings_autogen_wgl.h b/chromium/ui/gl/gl_bindings_autogen_wgl.h index 2377f416585..c6b787d395f 100644 --- a/chromium/ui/gl/gl_bindings_autogen_wgl.h +++ b/chromium/ui/gl/gl_bindings_autogen_wgl.h @@ -11,6 +11,8 @@ #ifndef UI_GL_GL_BINDINGS_AUTOGEN_WGL_H_ #define UI_GL_GL_BINDINGS_AUTOGEN_WGL_H_ +#include <string> + namespace gl { class GLContext; @@ -91,6 +93,8 @@ class GL_EXPORT WGLApi { WGLApi(); virtual ~WGLApi(); + virtual void SetDisabledExtensions(const std::string& disabled_extensions) {} + virtual BOOL wglChoosePixelFormatARBFn(HDC dc, const int* int_attrib_list, const float* float_attrib_list, diff --git a/chromium/ui/gl/gl_context.cc b/chromium/ui/gl/gl_context.cc index 80622b2f6e1..9dd442dc457 100644 --- a/chromium/ui/gl/gl_context.cc +++ b/chromium/ui/gl/gl_context.cc @@ -32,6 +32,13 @@ base::LazyInstance<base::ThreadLocalPointer<GLContext>>::Leaky current_real_context_ = LAZY_INSTANCE_INITIALIZER; } // namespace +// static +base::subtle::Atomic32 GLContext::total_gl_contexts_ = 0; +// static +bool GLContext::switchable_gpus_supported_ = false; +// static +GpuPreference GLContext::forced_gpu_preference_ = GpuPreferenceNone; + GLContext::ScopedReleaseCurrent::ScopedReleaseCurrent() : canceled_(false) {} GLContext::ScopedReleaseCurrent::~ScopedReleaseCurrent() { @@ -48,6 +55,7 @@ GLContext::GLContext(GLShareGroup* share_group) : share_group_(share_group) { if (!share_group_.get()) share_group_ = new gl::GLShareGroup(); share_group_->AddContext(this); + base::subtle::NoBarrier_AtomicIncrement(&total_gl_contexts_, 1); } GLContext::~GLContext() { @@ -56,12 +64,53 @@ GLContext::~GLContext() { SetCurrent(nullptr); SetCurrentGL(nullptr); } + base::subtle::Atomic32 after_value = + base::subtle::NoBarrier_AtomicIncrement(&total_gl_contexts_, -1); + DCHECK(after_value >= 0); +} + +// static +int32_t GLContext::TotalGLContexts() { + return static_cast<int32_t>( + base::subtle::NoBarrier_Load(&total_gl_contexts_)); +} + +// static +bool GLContext::SwitchableGPUsSupported() { + return switchable_gpus_supported_; +} + +// static +void GLContext::SetSwitchableGPUsSupported() { + DCHECK(!switchable_gpus_supported_); + switchable_gpus_supported_ = true; +} + +// static +void GLContext::SetForcedGpuPreference(GpuPreference gpu_preference) { + DCHECK_EQ(GpuPreferenceNone, forced_gpu_preference_); + forced_gpu_preference_ = gpu_preference; +} + +// static +GpuPreference GLContext::AdjustGpuPreference(GpuPreference gpu_preference) { + switch (forced_gpu_preference_) { + case GpuPreferenceNone: + return gpu_preference; + case PreferIntegratedGpu: + case PreferDiscreteGpu: + return forced_gpu_preference_; + default: + NOTREACHED(); + return GpuPreferenceNone; + } } GLApi* GLContext::CreateGLApi(DriverGL* driver) { real_gl_api_ = new RealGLApi; - real_gl_api_->Initialize(driver); real_gl_api_->set_gl_workarounds(gl_workarounds_); + real_gl_api_->SetDisabledExtensions(disabled_gl_extensions_); + real_gl_api_->Initialize(driver); return real_gl_api_; } @@ -76,11 +125,6 @@ void GLContext::SetUnbindFboOnMakeCurrent() { NOTIMPLEMENTED(); } -std::string GLContext::GetExtensions() { - DCHECK(IsCurrent(nullptr)); - return GetGLExtensionsFromCurrentContext(gl_api_.get()); -} - std::string GLContext::GetGLVersion() { DCHECK(IsCurrent(nullptr)); DCHECK(gl_api_ != nullptr); @@ -97,7 +141,8 @@ std::string GLContext::GetGLRenderer() { return std::string(renderer ? renderer : ""); } -YUVToRGBConverter* GLContext::GetYUVToRGBConverter() { +YUVToRGBConverter* GLContext::GetYUVToRGBConverter( + const gfx::ColorSpace& color_space) { return nullptr; } @@ -134,6 +179,7 @@ CurrentGL* GLContext::GetCurrentGL() { void GLContext::ReinitializeDynamicBindings() { DCHECK(IsCurrent(nullptr)); dynamic_bindings_initialized_ = false; + ResetExtensions(); InitializeDynamicBindings(); } @@ -142,13 +188,7 @@ void GLContext::ForceReleaseVirtuallyCurrent() { } bool GLContext::HasExtension(const char* name) { - std::string extensions = GetExtensions(); - extensions += " "; - - std::string delimited_name(name); - delimited_name += " "; - - return extensions.find(delimited_name) != std::string::npos; + return gl::HasExtension(GetExtensions(), name); } const GLVersionInfo* GLContext::GetVersionInfo() { @@ -196,7 +236,7 @@ GLContext* GLContext::GetRealCurrent() { std::unique_ptr<gl::GLVersionInfo> GLContext::GenerateGLVersionInfo() { return base::MakeUnique<GLVersionInfo>( - GetGLVersion().c_str(), GetGLRenderer().c_str(), GetExtensions().c_str()); + GetGLVersion().c_str(), GetGLRenderer().c_str(), GetExtensions()); } void GLContext::SetCurrent(GLSurface* surface) { @@ -212,11 +252,14 @@ void GLContext::SetCurrent(GLSurface* surface) { } void GLContext::SetGLWorkarounds(const GLWorkarounds& workarounds) { - DCHECK(IsCurrent(nullptr)); + DCHECK(!real_gl_api_); gl_workarounds_ = workarounds; - if (real_gl_api_) { - real_gl_api_->set_gl_workarounds(gl_workarounds_); - } +} + +void GLContext::SetDisabledGLExtensions( + const std::string& disabled_extensions) { + DCHECK(!real_gl_api_); + disabled_gl_extensions_ = disabled_extensions; } GLStateRestorer* GLContext::GetGLStateRestorer() { @@ -250,7 +293,11 @@ void GLContext::InitializeDynamicBindings() { DCHECK(static_bindings_initialized_); if (!dynamic_bindings_initialized_) { if (real_gl_api_) { - real_gl_api_->InitializeFilteredExtensions(); + // This is called everytime DoRequestExtensionCHROMIUM() is called in + // passthrough command buffer. So the underlying ANGLE driver will have + // different GL extensions, therefore we need to clear the cache and + // recompute on demand later. + real_gl_api_->ClearCachedGLExtensions(); real_gl_api_->set_version(GenerateGLVersionInfo()); } @@ -336,6 +383,14 @@ scoped_refptr<GPUTimingClient> GLContextReal::CreateGPUTimingClient() { return gpu_timing_->CreateGPUTimingClient(); } +const ExtensionSet& GLContextReal::GetExtensions() { + DCHECK(IsCurrent(nullptr)); + if (!extensions_initialized_) { + SetExtensionsFromString(GetGLExtensionsFromCurrentContext(gl_api())); + } + return extensions_; +} + GLContextReal::~GLContextReal() { if (GetRealCurrent() == this) current_real_context_.Pointer()->Set(nullptr); @@ -354,4 +409,16 @@ scoped_refptr<GLContext> InitializeGLContext(scoped_refptr<GLContext> context, return context; } +void GLContextReal::SetExtensionsFromString(std::string extensions) { + extensions_string_ = std::move(extensions); + extensions_ = MakeExtensionSet(extensions_string_); + extensions_initialized_ = true; +} + +void GLContextReal::ResetExtensions() { + extensions_.clear(); + extensions_string_.clear(); + extensions_initialized_ = false; +} + } // namespace gl diff --git a/chromium/ui/gl/gl_context.h b/chromium/ui/gl/gl_context.h index ff9cfdbbb5d..5fe126a56a1 100644 --- a/chromium/ui/gl/gl_context.h +++ b/chromium/ui/gl/gl_context.h @@ -7,18 +7,23 @@ #include <memory> #include <string> -#include <vector> +#include "base/atomicops.h" #include "base/cancelable_callback.h" #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/synchronization/cancellation_flag.h" +#include "ui/gl/extension_set.h" #include "ui/gl/gl_export.h" #include "ui/gl/gl_share_group.h" #include "ui/gl/gl_state_restorer.h" #include "ui/gl/gl_workarounds.h" #include "ui/gl/gpu_preference.h" +namespace gfx { +class ColorSpace; +} // namespace gfx + namespace gl { class YUVToRGBConverter; } // namespace gl @@ -74,6 +79,19 @@ class GL_EXPORT GLContext : public base::RefCounted<GLContext> { public: explicit GLContext(GLShareGroup* share_group); + static int32_t TotalGLContexts(); + + static bool SwitchableGPUsSupported(); + // This should be called at most once at GPU process startup time. + // By default, GPU switching is not supported unless this is called. + static void SetSwitchableGPUsSupported(); + + // This should be called at most once at GPU process startup time. + static void SetForcedGpuPreference(GpuPreference gpu_preference); + // If a gpu preference is forced (by GPU driver bug workaround, etc), return + // it. Otherwise, return the original input preference. + static GpuPreference AdjustGpuPreference(GpuPreference gpu_preference); + // Initializes the GL context to be compatible with the given surface. The GL // context can be made with other surface's of the same type. The compatible // surface is only needed for certain platforms like WGL, OSMesa and GLX. It @@ -100,6 +118,8 @@ class GL_EXPORT GLContext : public base::RefCounted<GLContext> { // Set the GL workarounds. void SetGLWorkarounds(const GLWorkarounds& workarounds); + void SetDisabledGLExtensions(const std::string& disabled_gl_extensions); + // Gets the GLStateRestorer for the context. GLStateRestorer* GetGLStateRestorer(); @@ -113,8 +133,8 @@ class GL_EXPORT GLContext : public base::RefCounted<GLContext> { // passed to SetSwapInterval. void ForceSwapIntervalZero(bool force); - // Returns space separated list of extensions. The context must be current. - virtual std::string GetExtensions(); + // Returns set of extensions. The context must be current. + virtual const ExtensionSet& GetExtensions() = 0; // Indicate that it is safe to force this context to switch GPUs, since // transitioning can cause corruption and hangs (OS X only). @@ -167,8 +187,10 @@ class GL_EXPORT GLContext : public base::RefCounted<GLContext> { // Returns the GL renderer string. The context must be current. virtual std::string GetGLRenderer(); - // Returns a helper structure to convert YUV textures to RGB textures. - virtual YUVToRGBConverter* GetYUVToRGBConverter(); + // Returns a helper structure to convert the YUV color space |color_space| + // to its associated full-range RGB color space. + virtual YUVToRGBConverter* GetYUVToRGBConverter( + const gfx::ColorSpace& color_space); // Get the CurrentGL object for this context containing the driver, version // and API. @@ -217,6 +239,9 @@ class GL_EXPORT GLContext : public base::RefCounted<GLContext> { static GLContext* GetRealCurrent(); virtual void OnSetSwapInterval(int interval) = 0; + virtual void ResetExtensions() = 0; + + GLApi* gl_api() { return gl_api_.get(); } private: friend class base::RefCounted<GLContext>; @@ -226,7 +251,14 @@ class GL_EXPORT GLContext : public base::RefCounted<GLContext> { std::unique_ptr<GLVersionInfo> GenerateGLVersionInfo(); + static base::subtle::Atomic32 total_gl_contexts_; + + static bool switchable_gpus_supported_; + + static GpuPreference forced_gpu_preference_; + GLWorkarounds gl_workarounds_; + std::string disabled_gl_extensions_; bool static_bindings_initialized_ = false; bool dynamic_bindings_initialized_ = false; @@ -256,14 +288,22 @@ class GL_EXPORT GLContextReal : public GLContext { public: explicit GLContextReal(GLShareGroup* share_group); scoped_refptr<GPUTimingClient> CreateGPUTimingClient() override; + const ExtensionSet& GetExtensions() override; protected: ~GLContextReal() override; + void ResetExtensions() override; + void SetCurrent(GLSurface* surface) override; + void SetExtensionsFromString(std::string extensions); + const std::string& extension_string() { return extensions_string_; } private: std::unique_ptr<GPUTiming> gpu_timing_; + std::string extensions_string_; + ExtensionSet extensions_; + bool extensions_initialized_ = false; DISALLOW_COPY_AND_ASSIGN(GLContextReal); }; diff --git a/chromium/ui/gl/gl_context_cgl.cc b/chromium/ui/gl/gl_context_cgl.cc index 06e5e73b93a..6b85039c6dd 100644 --- a/chromium/ui/gl/gl_context_cgl.cc +++ b/chromium/ui/gl/gl_context_cgl.cc @@ -46,7 +46,7 @@ static CGLPixelFormatObj GetPixelFormat() { std::vector<CGLPixelFormatAttribute> attribs; // If the system supports dual gpus then allow offline renderers for every // context, so that they can all be in the same share group. - if (ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) { + if (GLContext::SwitchableGPUsSupported()) { attribs.push_back(kCGLPFAAllowOfflineRenderers); g_support_renderer_switching = true; } @@ -101,8 +101,7 @@ bool GLContextCGL::Initialize(GLSurface* compatible_surface, attribs.bind_generates_resource); GpuPreference gpu_preference = - ui::GpuSwitchingManager::GetInstance()->AdjustGpuPreference( - attribs.gpu_preference); + GLContext::AdjustGpuPreference(attribs.gpu_preference); GLContextCGL* share_context = share_group() ? static_cast<GLContextCGL*>(share_group()->GetContext()) : nullptr; @@ -113,7 +112,7 @@ bool GLContextCGL::Initialize(GLSurface* compatible_surface, // If using the discrete gpu, create a pixel format requiring it before we // create the context. - if (!ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus() || + if (!GLContext::SwitchableGPUsSupported() || gpu_preference == PreferDiscreteGpu) { std::vector<CGLPixelFormatAttribute> discrete_attribs; discrete_attribs.push_back((CGLPixelFormatAttribute) 0); @@ -149,7 +148,7 @@ bool GLContextCGL::Initialize(GLSurface* compatible_surface, } void GLContextCGL::Destroy() { - if (yuv_to_rgb_converter_) { + if (!yuv_to_rgb_converters_.empty()) { // If this context is not current, bind this context's API so that the YUV // converter can safely destruct GLContext* current_context = GetRealCurrent(); @@ -158,7 +157,7 @@ void GLContextCGL::Destroy() { } ScopedCGLSetCurrentContext(static_cast<CGLContextObj>(context_)); - yuv_to_rgb_converter_.reset(); + yuv_to_rgb_converters_.clear(); // Rebind the current context's API if needed. if (current_context && current_context != this) { @@ -224,10 +223,14 @@ bool GLContextCGL::ForceGpuSwitchIfNeeded() { return true; } -YUVToRGBConverter* GLContextCGL::GetYUVToRGBConverter() { - if (!yuv_to_rgb_converter_) - yuv_to_rgb_converter_.reset(new YUVToRGBConverter(*GetVersionInfo())); - return yuv_to_rgb_converter_.get(); +YUVToRGBConverter* GLContextCGL::GetYUVToRGBConverter( + const gfx::ColorSpace& color_space) { + std::unique_ptr<YUVToRGBConverter>& yuv_to_rgb_converter = + yuv_to_rgb_converters_[color_space]; + if (!yuv_to_rgb_converter) + yuv_to_rgb_converter.reset( + new YUVToRGBConverter(*GetVersionInfo(), color_space)); + return yuv_to_rgb_converter.get(); } bool GLContextCGL::MakeCurrent(GLSurface* surface) { @@ -239,6 +242,16 @@ bool GLContextCGL::MakeCurrent(GLSurface* surface) { if (IsCurrent(surface)) return true; + // It's likely we're going to switch OpenGL contexts at this point. + // Before doing so, if there is a current context, flush it. There + // are many implicit assumptions of flush ordering between contexts + // at higher levels, and if a flush isn't performed, OpenGL commands + // may be issued in unexpected orders, causing flickering and other + // artifacts. + if (CGLGetCurrentContext() != nullptr) { + glFlush(); + } + ScopedReleaseCurrent release_current; TRACE_EVENT0("gpu", "GLContextCGL::MakeCurrent"); @@ -267,6 +280,12 @@ void GLContextCGL::ReleaseCurrent(GLSurface* surface) { if (!IsCurrent(surface)) return; + // Before releasing the current context, flush it. This ensures that + // all commands issued by higher levels will be seen by the OpenGL + // implementation, which is assumed throughout the code. See comment + // in MakeCurrent, above. + glFlush(); + SetCurrent(nullptr); CGLSetCurrentContext(nullptr); } diff --git a/chromium/ui/gl/gl_context_cgl.h b/chromium/ui/gl/gl_context_cgl.h index 72fbb4d6c8c..737f326c0f9 100644 --- a/chromium/ui/gl/gl_context_cgl.h +++ b/chromium/ui/gl/gl_context_cgl.h @@ -7,9 +7,11 @@ #include <OpenGL/CGLTypes.h> +#include <map> #include <memory> #include "base/macros.h" +#include "ui/gfx/color_space.h" #include "ui/gl/gl_context.h" #include "ui/gl/gl_export.h" @@ -32,7 +34,8 @@ class GL_EXPORT GLContextCGL : public GLContextReal { void OnSetSwapInterval(int interval) override; void SetSafeToForceGpuSwitch() override; bool ForceGpuSwitchIfNeeded() override; - YUVToRGBConverter* GetYUVToRGBConverter() override; + YUVToRGBConverter* GetYUVToRGBConverter( + const gfx::ColorSpace& color_space) override; protected: ~GLContextCGL() override; @@ -43,7 +46,8 @@ class GL_EXPORT GLContextCGL : public GLContextReal { void* context_; GpuPreference gpu_preference_; - std::unique_ptr<YUVToRGBConverter> yuv_to_rgb_converter_; + std::map<gfx::ColorSpace, std::unique_ptr<YUVToRGBConverter>> + yuv_to_rgb_converters_; CGLPixelFormatObj discrete_pixelformat_; diff --git a/chromium/ui/gl/gl_context_egl.cc b/chromium/ui/gl/gl_context_egl.cc index 2fbfe08205a..716c0ca6c1f 100644 --- a/chromium/ui/gl/gl_context_egl.cc +++ b/chromium/ui/gl/gl_context_egl.cc @@ -154,7 +154,7 @@ bool GLContextEGL::Initialize(GLSurface* compatible_surface, } } - if (GLSurfaceEGL::HasEGLExtension("EGL_ANGLE_display_texture_share_group")) { + if (GLSurfaceEGL::IsDisplayTextureShareGroupSupported()) { context_attributes.push_back(EGL_DISPLAY_TEXTURE_SHARE_GROUP_ANGLE); context_attributes.push_back( attribs.global_texture_share_group ? EGL_TRUE : EGL_FALSE); @@ -162,7 +162,7 @@ bool GLContextEGL::Initialize(GLSurface* compatible_surface, DCHECK(!attribs.global_texture_share_group); } - if (GLSurfaceEGL::HasEGLExtension("EGL_ANGLE_create_context_client_arrays")) { + if (GLSurfaceEGL::IsCreateContextClientArraysSupported()) { // Disable client arrays if the context supports it context_attributes.push_back(EGL_CONTEXT_CLIENT_ARRAYS_ENABLED_ANGLE); context_attributes.push_back(EGL_FALSE); @@ -291,15 +291,6 @@ void GLContextEGL::OnSetSwapInterval(int interval) { } } -std::string GLContextEGL::GetExtensions() { - const char* extensions = eglQueryString(display_, - EGL_EXTENSIONS); - if (!extensions) - return GLContext::GetExtensions(); - - return GLContext::GetExtensions() + " " + extensions; -} - bool GLContextEGL::WasAllocatedUsingRobustnessExtension() { return GLSurfaceEGL::IsCreateContextRobustnessSupported(); } diff --git a/chromium/ui/gl/gl_context_egl.h b/chromium/ui/gl/gl_context_egl.h index 6a436dc596d..75b2f3208c1 100644 --- a/chromium/ui/gl/gl_context_egl.h +++ b/chromium/ui/gl/gl_context_egl.h @@ -33,7 +33,6 @@ class GL_EXPORT GLContextEGL : public GLContextReal { bool IsCurrent(GLSurface* surface) override; void* GetHandle() override; void OnSetSwapInterval(int interval) override; - std::string GetExtensions() override; bool WasAllocatedUsingRobustnessExtension() override; void SetUnbindFboOnMakeCurrent() override; diff --git a/chromium/ui/gl/gl_context_glx.cc b/chromium/ui/gl/gl_context_glx.cc index a4493a29a3a..d66d3119382 100644 --- a/chromium/ui/gl/gl_context_glx.cc +++ b/chromium/ui/gl/gl_context_glx.cc @@ -172,16 +172,9 @@ bool GLContextGLX::Initialize(GLSurface* compatible_surface, if (GLSurfaceGLX::IsCreateContextSupported()) { DVLOG(1) << "GLX_ARB_create_context supported."; - if (base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kCreateDefaultGLContext)) { - context_ = CreateContextAttribs( - display_, static_cast<GLXFBConfig>(compatible_surface->GetConfig()), - share_handle, GLVersion(0, 0), 0); - } else { - context_ = CreateHighestVersionContext( - display_, static_cast<GLXFBConfig>(compatible_surface->GetConfig()), - share_handle); - } + context_ = CreateHighestVersionContext( + display_, static_cast<GLXFBConfig>(compatible_surface->GetConfig()), + share_handle); if (!context_) { LOG(ERROR) << "Failed to create GL context with " << "glXCreateContextAttribsARB."; @@ -304,16 +297,6 @@ void GLContextGLX::OnSetSwapInterval(int interval) { } } -std::string GLContextGLX::GetExtensions() { - DCHECK(IsCurrent(nullptr)); - const char* extensions = GLSurfaceGLX::GetGLXExtensions(); - if (extensions) { - return GLContext::GetExtensions() + " " + extensions; - } - - return GLContext::GetExtensions(); -} - bool GLContextGLX::WasAllocatedUsingRobustnessExtension() { return GLSurfaceGLX::IsCreateContextRobustnessSupported(); } diff --git a/chromium/ui/gl/gl_context_glx.h b/chromium/ui/gl/gl_context_glx.h index 62c78e73327..fd5d8d082ec 100644 --- a/chromium/ui/gl/gl_context_glx.h +++ b/chromium/ui/gl/gl_context_glx.h @@ -32,7 +32,6 @@ class GL_EXPORT GLContextGLX : public GLContextReal { bool IsCurrent(GLSurface* surface) override; void* GetHandle() override; void OnSetSwapInterval(int interval) override; - std::string GetExtensions() override; bool WasAllocatedUsingRobustnessExtension() override; protected: diff --git a/chromium/ui/gl/gl_context_stub.cc b/chromium/ui/gl/gl_context_stub.cc index 1c54f9dd42c..7f60b288cd8 100644 --- a/chromium/ui/gl/gl_context_stub.cc +++ b/chromium/ui/gl/gl_context_stub.cc @@ -13,8 +13,9 @@ GLContextStub::GLContextStub() : GLContextStub(nullptr) {} GLContextStub::GLContextStub(GLShareGroup* share_group) : GLContextReal(share_group), use_stub_api_(false), - version_str_("OpenGL ES 3.0"), - extensions_("GL_EXT_framebuffer_object") {} + version_str_("OpenGL ES 3.0") { + SetExtensionsString("GL_EXT_framebuffer_object"); +} bool GLContextStub::Initialize(GLSurface* compatible_surface, const GLContextAttribs& attribs) { @@ -56,16 +57,12 @@ bool GLContextStub::WasAllocatedUsingRobustnessExtension() { HasExtension("GL_KHR_robustness") || HasExtension("GL_EXT_robustness"); } -std::string GLContextStub::GetExtensions() { - return extensions_; -} - void GLContextStub::SetUseStubApi(bool stub_api) { use_stub_api_ = stub_api; } void GLContextStub::SetExtensionsString(const char* extensions) { - extensions_ = extensions; + SetExtensionsFromString(extensions); } void GLContextStub::SetGLVersionString(const char* version_str) { @@ -80,8 +77,8 @@ GLApi* GLContextStub::CreateGLApi(DriverGL* driver) { if (!version_str_.empty()) { stub_api->set_version(version_str_); } - if (!extensions_.empty()) { - stub_api->set_extensions(extensions_); + if (!extension_string().empty()) { + stub_api->set_extensions(extension_string()); } return stub_api; } diff --git a/chromium/ui/gl/gl_context_stub.h b/chromium/ui/gl/gl_context_stub.h index 7ddc3d1f028..ca1514ca875 100644 --- a/chromium/ui/gl/gl_context_stub.h +++ b/chromium/ui/gl/gl_context_stub.h @@ -30,7 +30,6 @@ class GL_EXPORT GLContextStub : public GLContextReal { std::string GetGLVersion() override; std::string GetGLRenderer() override; bool WasAllocatedUsingRobustnessExtension() override; - std::string GetExtensions() override; void SetUseStubApi(bool stub_api); void SetExtensionsString(const char* extensions); @@ -44,7 +43,6 @@ class GL_EXPORT GLContextStub : public GLContextReal { private: bool use_stub_api_; std::string version_str_; - std::string extensions_; DISALLOW_COPY_AND_ASSIGN(GLContextStub); }; diff --git a/chromium/ui/gl/gl_context_wgl.cc b/chromium/ui/gl/gl_context_wgl.cc index 726fcb62496..520b4cac101 100644 --- a/chromium/ui/gl/gl_context_wgl.cc +++ b/chromium/ui/gl/gl_context_wgl.cc @@ -162,19 +162,6 @@ void GLContextWGL::OnSetSwapInterval(int interval) { } } -std::string GLContextWGL::GetExtensions() { - const char* extensions = nullptr; - if (g_driver_wgl.fn.wglGetExtensionsStringARBFn) - extensions = wglGetExtensionsStringARB(GLSurfaceWGL::GetDisplayDC()); - else if (g_driver_wgl.fn.wglGetExtensionsStringEXTFn) - extensions = wglGetExtensionsStringEXT(); - - if (extensions) - return GLContext::GetExtensions() + " " + extensions; - - return GLContext::GetExtensions(); -} - GLContextWGL::~GLContextWGL() { Destroy(); } diff --git a/chromium/ui/gl/gl_context_wgl.h b/chromium/ui/gl/gl_context_wgl.h index aed32873305..52653a08ce0 100644 --- a/chromium/ui/gl/gl_context_wgl.h +++ b/chromium/ui/gl/gl_context_wgl.h @@ -29,7 +29,6 @@ class GL_EXPORT GLContextWGL : public GLContextReal { bool IsCurrent(GLSurface* surface) override; void* GetHandle() override; void OnSetSwapInterval(int interval) override; - std::string GetExtensions() override; private: ~GLContextWGL() override; diff --git a/chromium/ui/gl/gl_egl_api_implementation.cc b/chromium/ui/gl/gl_egl_api_implementation.cc index e0520524b4b..f3bcf751041 100644 --- a/chromium/ui/gl/gl_egl_api_implementation.cc +++ b/chromium/ui/gl/gl_egl_api_implementation.cc @@ -9,6 +9,7 @@ #include "base/strings/string_util.h" #include "ui/gl/gl_context.h" #include "ui/gl/gl_implementation.h" +#include "ui/gl/gl_surface_egl.h" namespace gl { @@ -68,22 +69,25 @@ RealEGLApi::~RealEGLApi() { } void RealEGLApi::Initialize(DriverEGL* driver) { - InitializeWithCommandLine(driver, base::CommandLine::ForCurrentProcess()); -} - -void RealEGLApi::InitializeWithCommandLine(DriverEGL* driver, - base::CommandLine* command_line) { - DCHECK(command_line); InitializeBase(driver); +} - const std::string disabled_extensions = command_line->GetSwitchValueASCII( - switches::kDisableGLExtensions); +void RealEGLApi::SetDisabledExtensions(const std::string& disabled_extensions) { + DCHECK(GLContext::TotalGLContexts() == 0); disabled_exts_.clear(); filtered_exts_.clear(); if (!disabled_extensions.empty()) { - disabled_exts_ = base::SplitString( - disabled_extensions, ", ;", - base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); + std::vector<std::string> candidates = + base::SplitString(disabled_extensions, ", ;", base::KEEP_WHITESPACE, + base::SPLIT_WANT_NONEMPTY); + for (const auto& ext : candidates) { + if (!base::StartsWith(ext, "EGL_", base::CompareCase::SENSITIVE)) + continue; + // For the moment, only the following two extensions can be disabled. + // See DriverEGL::UpdateConditionalExtensionBindings(). + DCHECK(ext == "EGL_KHR_fence_sync" || ext == "EGL_KHR_wait_sync"); + disabled_exts_.push_back(ext); + } } } @@ -104,9 +108,23 @@ DebugEGLApi::DebugEGLApi(EGLApi* egl_api) : egl_api_(egl_api) {} DebugEGLApi::~DebugEGLApi() {} +void DebugEGLApi::SetDisabledExtensions( + const std::string& disabled_extensions) { + if (egl_api_) { + egl_api_->SetDisabledExtensions(disabled_extensions); + } +} + TraceEGLApi::~TraceEGLApi() { } +void TraceEGLApi::SetDisabledExtensions( + const std::string& disabled_extensions) { + if (egl_api_) { + egl_api_->SetDisabledExtensions(disabled_extensions); + } +} + bool GetGLWindowSystemBindingInfoEGL(GLWindowSystemBindingInfo* info) { EGLDisplay display = eglGetCurrentDisplay(); const char* vendor = eglQueryString(display, EGL_VENDOR); @@ -122,4 +140,14 @@ bool GetGLWindowSystemBindingInfoEGL(GLWindowSystemBindingInfo* info) { return true; } +void SetDisabledExtensionsEGL(const std::string& disabled_extensions) { + DCHECK(g_current_egl_context); + DCHECK(GLContext::TotalGLContexts() == 0); + g_current_egl_context->SetDisabledExtensions(disabled_extensions); +} + +bool InitializeExtensionSettingsOneOffEGL() { + return GLSurfaceEGL::InitializeExtensionSettingsOneOff(); +} + } // namespace gl diff --git a/chromium/ui/gl/gl_egl_api_implementation.h b/chromium/ui/gl/gl_egl_api_implementation.h index f120aab53fe..2c44df7d937 100644 --- a/chromium/ui/gl/gl_egl_api_implementation.h +++ b/chromium/ui/gl/gl_egl_api_implementation.h @@ -6,15 +6,13 @@ #define UI_GL_GL_EGL_API_IMPLEMENTATION_H_ #include <map> +#include <string> #include <vector> #include "base/compiler_specific.h" #include "ui/gl/gl_bindings.h" #include "ui/gl/gl_export.h" -namespace base { -class CommandLine; -} namespace gl { struct GLWindowSystemBindingInfo; @@ -23,6 +21,8 @@ GL_EXPORT void InitializeStaticGLBindingsEGL(); GL_EXPORT void InitializeDebugGLBindingsEGL(); GL_EXPORT void ClearBindingsEGL(); GL_EXPORT bool GetGLWindowSystemBindingInfoEGL(GLWindowSystemBindingInfo* info); +GL_EXPORT void SetDisabledExtensionsEGL(const std::string& disabled_extensions); +GL_EXPORT bool InitializeExtensionSettingsOneOffEGL(); class GL_EXPORT EGLApiBase : public EGLApi { public: @@ -44,8 +44,7 @@ class GL_EXPORT RealEGLApi : public EGLApiBase { RealEGLApi(); ~RealEGLApi() override; void Initialize(DriverEGL* driver); - void InitializeWithCommandLine(DriverEGL* driver, - base::CommandLine* command_line); + void SetDisabledExtensions(const std::string& disabled_extensions) override; const char* eglQueryStringFn(EGLDisplay dpy, EGLint name) override; @@ -60,6 +59,7 @@ class GL_EXPORT DebugEGLApi : public EGLApi { public: DebugEGLApi(EGLApi* egl_api); ~DebugEGLApi() override; + void SetDisabledExtensions(const std::string& disabled_extensions) override; // Include the auto-generated part of this class. We split this because // it means we can easily edit the non-auto generated parts right here in @@ -75,6 +75,7 @@ class GL_EXPORT TraceEGLApi : public EGLApi { public: TraceEGLApi(EGLApi* egl_api) : egl_api_(egl_api) { } ~TraceEGLApi() override; + void SetDisabledExtensions(const std::string& disabled_extensions) override; // Include the auto-generated part of this class. We split this because // it means we can easily edit the non-auto generated parts right here in @@ -88,6 +89,3 @@ class GL_EXPORT TraceEGLApi : public EGLApi { } // namespace gl #endif // UI_GL_GL_EGL_API_IMPLEMENTATION_H_ - - - diff --git a/chromium/ui/gl/gl_enums_implementation_autogen.h b/chromium/ui/gl/gl_enums_implementation_autogen.h index a7469082237..d9d51d8054f 100644 --- a/chromium/ui/gl/gl_enums_implementation_autogen.h +++ b/chromium/ui/gl/gl_enums_implementation_autogen.h @@ -1909,6 +1909,21 @@ static const GLEnums::EnumToString enum_to_string_table[] = { 0x8A57, "GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT", }, { + 0x8AF0, "GL_TEXTURE_FILTERING_HINT_CHROMIUM", + }, + { + 0x8AF1, "GL_COLOR_SPACE_UNSPECIFIED_CHROMIUM", + }, + { + 0x8AF2, "GL_COLOR_SPACE_SCRGB_LINEAR_CHROMIUM", + }, + { + 0x8AF3, "GL_COLOR_SPACE_SRGB_CHROMIUM", + }, + { + 0x8AF4, "GL_COLOR_SPACE_DISPLAY_P3_CHROMIUM", + }, + { 0x8B30, "GL_FRAGMENT_SHADER", }, { diff --git a/chromium/ui/gl/gl_gl_api_implementation.cc b/chromium/ui/gl/gl_gl_api_implementation.cc index bc55bfb5433..592e1ac511f 100644 --- a/chromium/ui/gl/gl_gl_api_implementation.cc +++ b/chromium/ui/gl/gl_gl_api_implementation.cc @@ -6,7 +6,6 @@ #include <vector> -#include "base/command_line.h" #include "base/memory/ptr_util.h" #include "base/stl_util.h" #include "base/strings/string_split.h" @@ -283,37 +282,18 @@ void GLApiBase::InitializeBase(DriverGL* driver) { } RealGLApi::RealGLApi() { -#if DCHECK_IS_ON() - filtered_exts_initialized_ = false; -#endif } RealGLApi::~RealGLApi() { } void RealGLApi::Initialize(DriverGL* driver) { - InitializeWithCommandLine(driver, base::CommandLine::ForCurrentProcess()); -} - -void RealGLApi::InitializeWithCommandLine(DriverGL* driver, - base::CommandLine* command_line) { - DCHECK(command_line); InitializeBase(driver); - - const std::string disabled_extensions = command_line->GetSwitchValueASCII( - switches::kDisableGLExtensions); - if (!disabled_extensions.empty()) { - disabled_exts_ = base::SplitString( - disabled_extensions, ", ;", - base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); - } } void RealGLApi::glGetIntegervFn(GLenum pname, GLint* params) { if (pname == GL_NUM_EXTENSIONS && disabled_exts_.size()) { -#if DCHECK_IS_ON() - DCHECK(filtered_exts_initialized_); -#endif + InitializeFilteredExtensionsIfNeeded(); *params = static_cast<GLint>(filtered_exts_.size()); } else { GLApiBase::glGetIntegervFn(pname, params); @@ -322,9 +302,7 @@ void RealGLApi::glGetIntegervFn(GLenum pname, GLint* params) { const GLubyte* RealGLApi::glGetStringFn(GLenum name) { if (name == GL_EXTENSIONS && disabled_exts_.size()) { -#if DCHECK_IS_ON() - DCHECK(filtered_exts_initialized_); -#endif + InitializeFilteredExtensionsIfNeeded(); return reinterpret_cast<const GLubyte*>(filtered_exts_str_.c_str()); } return GLApiBase::glGetStringFn(name); @@ -332,11 +310,9 @@ const GLubyte* RealGLApi::glGetStringFn(GLenum name) { const GLubyte* RealGLApi::glGetStringiFn(GLenum name, GLuint index) { if (name == GL_EXTENSIONS && disabled_exts_.size()) { -#if DCHECK_IS_ON() - DCHECK(filtered_exts_initialized_); -#endif + InitializeFilteredExtensionsIfNeeded(); if (index >= filtered_exts_.size()) { - return NULL; + return nullptr; } return reinterpret_cast<const GLubyte*>(filtered_exts_[index].c_str()); } @@ -356,6 +332,21 @@ void RealGLApi::glTexImage2DFn(GLenum target, GetTexInternalFormat(version_.get(), internalformat, format, type); GLenum gl_format = GetTexFormat(version_.get(), format); GLenum gl_type = GetTexType(version_.get(), type); + + // TODO(yizhou): Check if cubemap, 3d texture or texture2d array has the same + // bug on intel mac. + if (gl_workarounds_.reset_teximage2d_base_level && target == GL_TEXTURE_2D) { + GLint base_level = 0; + GLApiBase::glGetTexParameterivFn(target, GL_TEXTURE_BASE_LEVEL, + &base_level); + if (base_level) { + GLApiBase::glTexParameteriFn(target, GL_TEXTURE_BASE_LEVEL, 0); + GLApiBase::glTexImage2DFn(target, level, gl_internal_format, width, + height, border, gl_format, gl_type, pixels); + GLApiBase::glTexParameteriFn(target, GL_TEXTURE_BASE_LEVEL, base_level); + return; + } + } GLApiBase::glTexImage2DFn(target, level, gl_internal_format, width, height, border, gl_format, gl_type, pixels); } @@ -478,34 +469,47 @@ void RealGLApi::glDepthRangeFn(GLclampd z_near, GLclampd z_far) { } } -void RealGLApi::InitializeFilteredExtensions() { - if (disabled_exts_.size()) { - filtered_exts_.clear(); - if (WillUseGLGetStringForExtensions(this)) { - filtered_exts_str_ = - FilterGLExtensionList(reinterpret_cast<const char*>( - GLApiBase::glGetStringFn(GL_EXTENSIONS)), - disabled_exts_); - filtered_exts_ = base::SplitString( - filtered_exts_str_, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); - } else { - GLint num_extensions = 0; - GLApiBase::glGetIntegervFn(GL_NUM_EXTENSIONS, &num_extensions); - for (GLint i = 0; i < num_extensions; ++i) { - const char* gl_extension = reinterpret_cast<const char*>( - GLApiBase::glGetStringiFn(GL_EXTENSIONS, i)); - DCHECK(gl_extension != NULL); - if (!base::ContainsValue(disabled_exts_, gl_extension)) - filtered_exts_.push_back(gl_extension); - } - filtered_exts_str_ = base::JoinString(filtered_exts_, " "); +void RealGLApi::InitializeFilteredExtensionsIfNeeded() { + DCHECK(disabled_exts_.size()); + if (filtered_exts_.size()) + return; + DCHECK(filtered_exts_str_.empty()); + if (WillUseGLGetStringForExtensions(this)) { + filtered_exts_str_ = FilterGLExtensionList( + reinterpret_cast<const char*>(GLApiBase::glGetStringFn(GL_EXTENSIONS)), + disabled_exts_); + filtered_exts_ = base::SplitString( + filtered_exts_str_, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); + } else { + GLint num_extensions = 0; + GLApiBase::glGetIntegervFn(GL_NUM_EXTENSIONS, &num_extensions); + for (GLint i = 0; i < num_extensions; ++i) { + const char* gl_extension = reinterpret_cast<const char*>( + GLApiBase::glGetStringiFn(GL_EXTENSIONS, i)); + DCHECK(gl_extension); + if (!base::ContainsValue(disabled_exts_, gl_extension)) + filtered_exts_.push_back(gl_extension); } -#if DCHECK_IS_ON() - filtered_exts_initialized_ = true; -#endif + filtered_exts_str_ = base::JoinString(filtered_exts_, " "); } } +void RealGLApi::SetDisabledExtensions(const std::string& disabled_extensions) { + ClearCachedGLExtensions(); + disabled_exts_.clear(); + if (disabled_extensions.empty()) + return; + disabled_exts_ = + base::SplitString(disabled_extensions, ", ;", base::KEEP_WHITESPACE, + base::SPLIT_WANT_NONEMPTY); + DCHECK(disabled_exts_.size()); +} + +void RealGLApi::ClearCachedGLExtensions() { + filtered_exts_.clear(); + filtered_exts_str_.clear(); +} + void RealGLApi::set_gl_workarounds(const GLWorkarounds& workarounds) { gl_workarounds_ = workarounds; } diff --git a/chromium/ui/gl/gl_gl_api_implementation.h b/chromium/ui/gl/gl_gl_api_implementation.h index db0fcc720a2..e6311517adf 100644 --- a/chromium/ui/gl/gl_gl_api_implementation.h +++ b/chromium/ui/gl/gl_gl_api_implementation.h @@ -13,10 +13,6 @@ #include "ui/gl/gl_export.h" #include "ui/gl/gl_workarounds.h" -namespace base { -class CommandLine; -} - namespace gl { struct GLVersionInfo; @@ -53,8 +49,7 @@ class GL_EXPORT RealGLApi : public GLApiBase { RealGLApi(); ~RealGLApi() override; void Initialize(DriverGL* driver); - void InitializeWithCommandLine(DriverGL* driver, - base::CommandLine* command_line); + void SetDisabledExtensions(const std::string& disabled_extensions) override; void glGetIntegervFn(GLenum pname, GLint* params) override; const GLubyte* glGetStringFn(GLenum name) override; @@ -117,22 +112,21 @@ class GL_EXPORT RealGLApi : public GLApiBase { void glClearDepthFn(GLclampd depth) override; void glDepthRangeFn(GLclampd z_near, GLclampd z_far) override; - void InitializeFilteredExtensions(); void set_gl_workarounds(const GLWorkarounds& workarounds); void set_version(std::unique_ptr<GLVersionInfo> version); + void ClearCachedGLExtensions(); private: - // Filtered GL_EXTENSIONS we return to glGetString(i) calls. + // Compute |filtered_exts_| & |filtered_exts_str_| from |disabled_ext_|. + void InitializeFilteredExtensionsIfNeeded(); + std::vector<std::string> disabled_exts_; + // Filtered GL_EXTENSIONS we return to glGetString(i) calls. std::vector<std::string> filtered_exts_; std::string filtered_exts_str_; GLWorkarounds gl_workarounds_; std::unique_ptr<GLVersionInfo> version_; - -#if DCHECK_IS_ON() - bool filtered_exts_initialized_; -#endif }; // Inserts a TRACE for every GL call. diff --git a/chromium/ui/gl/gl_glx_api_implementation.cc b/chromium/ui/gl/gl_glx_api_implementation.cc index 413a385f2e6..d7903a2654d 100644 --- a/chromium/ui/gl/gl_glx_api_implementation.cc +++ b/chromium/ui/gl/gl_glx_api_implementation.cc @@ -7,7 +7,9 @@ #include "base/command_line.h" #include "base/strings/string_split.h" #include "base/strings/string_util.h" +#include "ui/gl/gl_context.h" #include "ui/gl/gl_implementation.h" +#include "ui/gl/gl_surface_glx.h" namespace gl { @@ -21,7 +23,6 @@ void InitializeStaticGLBindingsGLX() { } g_real_glx->Initialize(&g_driver_glx); g_current_glx_context = g_real_glx; - g_driver_glx.InitializeExtensionBindings(); } void InitializeDebugGLBindingsGLX() { @@ -68,16 +69,10 @@ RealGLXApi::~RealGLXApi() { } void RealGLXApi::Initialize(DriverGLX* driver) { - InitializeWithCommandLine(driver, base::CommandLine::ForCurrentProcess()); -} - -void RealGLXApi::InitializeWithCommandLine(DriverGLX* driver, - base::CommandLine* command_line) { - DCHECK(command_line); InitializeBase(driver); +} - const std::string disabled_extensions = command_line->GetSwitchValueASCII( - switches::kDisableGLExtensions); +void RealGLXApi::SetDisabledExtensions(const std::string& disabled_extensions) { disabled_exts_.clear(); filtered_exts_ = ""; if (!disabled_extensions.empty()) { @@ -105,11 +100,26 @@ const char* RealGLXApi::glXQueryExtensionsStringFn(Display* dpy, } DebugGLXApi::DebugGLXApi(GLXApi* glx_api) : glx_api_(glx_api) {} + DebugGLXApi::~DebugGLXApi() {} +void DebugGLXApi::SetDisabledExtensions( + const std::string& disabled_extensions) { + if (glx_api_) { + glx_api_->SetDisabledExtensions(disabled_extensions); + } +} + TraceGLXApi::~TraceGLXApi() { } +void TraceGLXApi::SetDisabledExtensions( + const std::string& disabled_extensions) { + if (glx_api_) { + glx_api_->SetDisabledExtensions(disabled_extensions); + } +} + bool GetGLWindowSystemBindingInfoGLX(GLWindowSystemBindingInfo* info) { Display* display = glXGetCurrentDisplay(); const int kDefaultScreen = 0; @@ -130,4 +140,14 @@ bool GetGLWindowSystemBindingInfoGLX(GLWindowSystemBindingInfo* info) { return true; } +void SetDisabledExtensionsGLX(const std::string& disabled_extensions) { + DCHECK(g_current_glx_context); + DCHECK(GLContext::TotalGLContexts() == 0); + g_current_glx_context->SetDisabledExtensions(disabled_extensions); +} + +bool InitializeExtensionSettingsOneOffGLX() { + return GLSurfaceGLX::InitializeExtensionSettingsOneOff(); +} + } // namespace gl diff --git a/chromium/ui/gl/gl_glx_api_implementation.h b/chromium/ui/gl/gl_glx_api_implementation.h index 2c1815757ca..f3ac47ec91c 100644 --- a/chromium/ui/gl/gl_glx_api_implementation.h +++ b/chromium/ui/gl/gl_glx_api_implementation.h @@ -5,15 +5,13 @@ #ifndef UI_GL_GL_GLX_API_IMPLEMENTATION_H_ #define UI_GL_GL_GLX_API_IMPLEMENTATION_H_ +#include <string> #include <vector> #include "base/compiler_specific.h" #include "gl_bindings.h" #include "ui/gl/gl_export.h" -namespace base { -class CommandLine; -} namespace gl { struct GLWindowSystemBindingInfo; @@ -22,6 +20,8 @@ GL_EXPORT void InitializeStaticGLBindingsGLX(); GL_EXPORT void InitializeDebugGLBindingsGLX(); GL_EXPORT void ClearBindingsGLX(); GL_EXPORT bool GetGLWindowSystemBindingInfoGLX(GLWindowSystemBindingInfo* info); +GL_EXPORT void SetDisabledExtensionsGLX(const std::string& disabled_extensions); +GL_EXPORT bool InitializeExtensionSettingsOneOffGLX(); class GL_EXPORT GLXApiBase : public GLXApi { public: @@ -43,8 +43,7 @@ class GL_EXPORT RealGLXApi : public GLXApiBase { RealGLXApi(); ~RealGLXApi() override; void Initialize(DriverGLX* driver); - void InitializeWithCommandLine(DriverGLX* driver, - base::CommandLine* command_line); + void SetDisabledExtensions(const std::string& disabled_extensions) override; const char* glXQueryExtensionsStringFn(Display* dpy, int screen) override; private: @@ -59,6 +58,8 @@ class GL_EXPORT DebugGLXApi : public GLXApi { DebugGLXApi(GLXApi* glx_api); ~DebugGLXApi() override; + void SetDisabledExtensions(const std::string& disabled_extensions) override; + // Include the auto-generated part of this class. We split this because // it means we can easily edit the non-auto generated parts right here in // this file instead of having to edit some template or the code generator. @@ -74,6 +75,8 @@ class GL_EXPORT TraceGLXApi : public GLXApi { TraceGLXApi(GLXApi* glx_api) : glx_api_(glx_api) { } ~TraceGLXApi() override; + void SetDisabledExtensions(const std::string& disabled_extensions) override; + // Include the auto-generated part of this class. We split this because // it means we can easily edit the non-auto generated parts right here in // this file instead of having to edit some template or the code generator. @@ -86,6 +89,3 @@ class GL_EXPORT TraceGLXApi : public GLXApi { } // namespace gl #endif // UI_GL_GL_GLX_API_IMPLEMENTATION_H_ - - - diff --git a/chromium/ui/gl/gl_image.h b/chromium/ui/gl/gl_image.h index 3e34bbf32b0..c29eff60d28 100644 --- a/chromium/ui/gl/gl_image.h +++ b/chromium/ui/gl/gl_image.h @@ -11,6 +11,7 @@ #include "base/macros.h" #include "base/memory/ref_counted.h" +#include "ui/gfx/color_space.h" #include "ui/gfx/geometry/point.h" #include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect_f.h" @@ -96,9 +97,17 @@ class GL_EXPORT GLImage : public base::RefCounted<GLImage> { enum class Type { NONE, MEMORY, IOSURFACE, DXGI_IMAGE }; virtual Type GetType() const; + void SetColorSpaceForScanout(const gfx::ColorSpace& color_space) { + color_space_ = color_space; + } + + const gfx::ColorSpace& color_space() const { return color_space_; } + protected: virtual ~GLImage() {} + gfx::ColorSpace color_space_; + private: friend class base::RefCounted<GLImage>; diff --git a/chromium/ui/gl/gl_image_io_surface.h b/chromium/ui/gl/gl_image_io_surface.h index 9cffcec6254..bf5f0699d96 100644 --- a/chromium/ui/gl/gl_image_io_surface.h +++ b/chromium/ui/gl/gl_image_io_surface.h @@ -71,6 +71,11 @@ class GL_EXPORT GLImageIOSurface : public GLImage { // signal about whether the Window Server is still using the IOSurface. bool CanCheckIOSurfaceIsInUse() const; + // For IOSurfaces that need manual conversion to a GL texture before being + // sampled from, specify the color space in which to do the required YUV to + // RGB transformation. + void SetColorSpaceForYUVToRGBConversion(const gfx::ColorSpace& color_space); + static unsigned GetInternalFormatForTesting(gfx::BufferFormat format); // Downcasts from |image|. Returns |nullptr| on failure. @@ -97,6 +102,8 @@ class GL_EXPORT GLImageIOSurface : public GLImage { base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer_; gfx::GenericSharedMemoryId io_surface_id_; base::ThreadChecker thread_checker_; + // The default value of Rec. 601 is based on historical shader code. + gfx::ColorSpace color_space_for_yuv_to_rgb_ = gfx::ColorSpace::CreateREC601(); DISALLOW_COPY_AND_ASSIGN(GLImageIOSurface); }; diff --git a/chromium/ui/gl/gl_image_io_surface.mm b/chromium/ui/gl/gl_image_io_surface.mm index c9fabee5a26..1dc5a6dbf1f 100644 --- a/chromium/ui/gl/gl_image_io_surface.mm +++ b/chromium/ui/gl/gl_image_io_surface.mm @@ -14,6 +14,7 @@ #include "base/trace_event/memory_dump_manager.h" #include "base/trace_event/process_memory_dump.h" #include "base/trace_event/trace_event.h" +#include "ui/gfx/color_space.h" #include "ui/gl/gl_bindings.h" #include "ui/gl/gl_context.h" #include "ui/gl/scoped_binders.h" @@ -298,7 +299,8 @@ bool GLImageIOSurface::CopyTexImage(unsigned target) { GLContext* gl_context = GLContext::GetCurrent(); DCHECK(gl_context); - YUVToRGBConverter* yuv_to_rgb_converter = gl_context->GetYUVToRGBConverter(); + YUVToRGBConverter* yuv_to_rgb_converter = + gl_context->GetYUVToRGBConverter(color_space_for_yuv_to_rgb_); DCHECK(yuv_to_rgb_converter); // Note that state restoration is done explicitly instead of scoped binders to @@ -405,6 +407,13 @@ bool GLImageIOSurface::CanCheckIOSurfaceIsInUse() const { return !cv_pixel_buffer_; } +void GLImageIOSurface::SetColorSpaceForYUVToRGBConversion( + const gfx::ColorSpace& color_space) { + DCHECK(color_space.IsValid()); + DCHECK_NE(color_space, color_space.GetAsFullRangeRGB()); + color_space_for_yuv_to_rgb_ = color_space; +} + base::ScopedCFTypeRef<IOSurfaceRef> GLImageIOSurface::io_surface() { return io_surface_; } diff --git a/chromium/ui/gl/gl_image_io_surface_unittest.cc b/chromium/ui/gl/gl_image_io_surface_unittest.cc index 31dd78b8280..a55e63f1697 100644 --- a/chromium/ui/gl/gl_image_io_surface_unittest.cc +++ b/chromium/ui/gl/gl_image_io_surface_unittest.cc @@ -14,10 +14,10 @@ namespace gl { namespace { -// These values are picked so that RGB -> YUV on the CPU converted -// back to RGB on the GPU produces the original RGB values without -// any error. -const uint8_t kYuvImageColor[] = {0x10, 0x20, 0, 0xFF}; +// These values are picked so that RGB -> YUV on the CPU converted back to RGB +// on the GPU produces the original RGB values without any error. Note that +// some values will be off-by-one. +const uint8_t kYuvImageColor[] = {0x30, 0x40, 0x10, 0xFF}; template <gfx::BufferFormat format> class GLImageIOSurfaceTestDelegate { diff --git a/chromium/ui/gl/gl_image_shared_memory.cc b/chromium/ui/gl/gl_image_shared_memory.cc index cef422b4a16..3b832c9e04e 100644 --- a/chromium/ui/gl/gl_image_shared_memory.cc +++ b/chromium/ui/gl/gl_image_shared_memory.cc @@ -13,7 +13,6 @@ #include "base/trace_event/memory_dump_manager.h" #include "base/trace_event/process_memory_dump.h" #include "ui/gfx/buffer_format_util.h" -#include "ui/gfx/gpu_memory_buffer_tracing.h" namespace gl { @@ -87,11 +86,9 @@ void GLImageSharedMemory::OnMemoryDump( base::trace_event::MemoryAllocatorDump::kUnitsBytes, static_cast<uint64_t>(size_in_bytes)); - auto guid = - gfx::GetSharedMemoryGUIDForTracing(process_tracing_id, shared_memory_id_); auto shared_memory_guid = shared_memory_->mapped_id(); if (!shared_memory_guid.is_empty()) { - pmd->CreateSharedMemoryOwnershipEdge(dump->guid(), guid, shared_memory_guid, + pmd->CreateSharedMemoryOwnershipEdge(dump->guid(), shared_memory_guid, 0 /* importance */); } } diff --git a/chromium/ui/gl/gl_image_stub.cc b/chromium/ui/gl/gl_image_stub.cc index 5bfd62be2f7..3d99c4e7eec 100644 --- a/chromium/ui/gl/gl_image_stub.cc +++ b/chromium/ui/gl/gl_image_stub.cc @@ -21,13 +21,13 @@ unsigned GLImageStub::GetInternalFormat() { return GL_RGBA; } bool GLImageStub::BindTexImage(unsigned target) { return true; } bool GLImageStub::CopyTexImage(unsigned target) { - return true; + return false; } bool GLImageStub::CopyTexSubImage(unsigned target, const gfx::Point& offset, const gfx::Rect& rect) { - return true; + return false; } bool GLImageStub::ScheduleOverlayPlane(gfx::AcceleratedWidget widget, diff --git a/chromium/ui/gl/gl_implementation.cc b/chromium/ui/gl/gl_implementation.cc index 8942d7e8733..c97e8f37bfd 100644 --- a/chromium/ui/gl/gl_implementation.cc +++ b/chromium/ui/gl/gl_implementation.cc @@ -82,7 +82,11 @@ GLImplementation GetNamedGLImplementation(const std::string& name) { } GLImplementation GetSoftwareGLImplementation() { +#if defined(OS_WIN) + return kGLImplementationSwiftShaderGL; +#else return kGLImplementationOSMesaGL; +#endif } const char* GetGLImplementationName(GLImplementation implementation) { @@ -225,14 +229,6 @@ bool WillUseGLGetStringForExtensions(GLApi* api) { return is_es || major_version < 3; } -std::unique_ptr<GLVersionInfo> GetVersionInfoFromContext(GLApi* api) { - std::string extensions = GetGLExtensionsFromCurrentContext(api); - return base::MakeUnique<GLVersionInfo>( - reinterpret_cast<const char*>(api->glGetStringFn(GL_VERSION)), - reinterpret_cast<const char*>(api->glGetStringFn(GL_RENDERER)), - extensions.c_str()); -} - base::NativeLibrary LoadLibraryAndPrintError( const base::FilePath::CharType* filename) { return LoadLibraryAndPrintError(base::FilePath(filename)); diff --git a/chromium/ui/gl/gl_implementation.h b/chromium/ui/gl/gl_implementation.h index 28cbde27188..507b39fbf10 100644 --- a/chromium/ui/gl/gl_implementation.h +++ b/chromium/ui/gl/gl_implementation.h @@ -18,7 +18,6 @@ namespace gl { class GLApi; -struct GLVersionInfo; // The GL implementation currently in use. enum GLImplementation { @@ -126,8 +125,6 @@ GL_EXPORT std::string GetGLExtensionsFromCurrentContext(GLApi* api); GL_EXPORT bool WillUseGLGetStringForExtensions(); GL_EXPORT bool WillUseGLGetStringForExtensions(GLApi* api); -GL_EXPORT std::unique_ptr<GLVersionInfo> GetVersionInfoFromContext(GLApi* api); - // Helpers to load a library and log error on failure. GL_EXPORT base::NativeLibrary LoadLibraryAndPrintError( const base::FilePath::CharType* filename); diff --git a/chromium/ui/gl/gl_mock_autogen_gl.h b/chromium/ui/gl/gl_mock_autogen_gl.h index 60f96b0b58a..4e89f056eee 100644 --- a/chromium/ui/gl/gl_mock_autogen_gl.h +++ b/chromium/ui/gl/gl_mock_autogen_gl.h @@ -515,6 +515,7 @@ MOCK_METHOD6(GetInternalformativRobustANGLE, GLsizei bufSize, GLsizei* length, GLint* params)); +MOCK_METHOD3(GetMultisamplefv, void(GLenum pname, GLuint index, GLfloat* val)); MOCK_METHOD5(GetMultisamplefvRobustANGLE, void(GLenum pname, GLuint index, @@ -876,6 +877,7 @@ MOCK_METHOD3(PathStencilFuncNV, void(GLenum func, GLint ref, GLuint mask)); MOCK_METHOD0(PauseTransformFeedback, void()); MOCK_METHOD2(PixelStorei, void(GLenum pname, GLint param)); MOCK_METHOD2(PointParameteri, void(GLenum pname, GLint param)); +MOCK_METHOD2(PolygonMode, void(GLenum face, GLenum mode)); MOCK_METHOD2(PolygonOffset, void(GLfloat factor, GLfloat units)); MOCK_METHOD0(PopDebugGroup, void()); MOCK_METHOD0(PopGroupMarkerEXT, void()); @@ -1032,6 +1034,14 @@ MOCK_METHOD4(StencilThenCoverStrokePathNV, void(GLuint path, GLint reference, GLuint mask, GLenum coverMode)); MOCK_METHOD1(TestFenceAPPLE, GLboolean(GLuint fence)); MOCK_METHOD1(TestFenceNV, GLboolean(GLuint fence)); +MOCK_METHOD3(TexBuffer, + void(GLenum target, GLenum internalformat, GLuint buffer)); +MOCK_METHOD5(TexBufferRange, + void(GLenum target, + GLenum internalformat, + GLuint buffer, + GLintptr offset, + GLsizeiptr size)); MOCK_METHOD9(TexImage2D, void(GLenum target, GLint level, @@ -1237,4 +1247,4 @@ MOCK_METHOD6(VertexAttribPointer, GLsizei stride, const void* ptr)); MOCK_METHOD4(Viewport, void(GLint x, GLint y, GLsizei width, GLsizei height)); -MOCK_METHOD3(WaitSync, GLenum(GLsync sync, GLbitfield flags, GLuint64 timeout)); +MOCK_METHOD3(WaitSync, void(GLsync sync, GLbitfield flags, GLuint64 timeout)); diff --git a/chromium/ui/gl/gl_stub_api.cc b/chromium/ui/gl/gl_stub_api.cc index c7ce0ba6f7b..e73f87a611d 100644 --- a/chromium/ui/gl/gl_stub_api.cc +++ b/chromium/ui/gl/gl_stub_api.cc @@ -336,10 +336,4 @@ GLboolean GLStubApi::glUnmapBufferFn(GLenum target) { return GL_TRUE; } -GLenum GLStubApi::glWaitSyncFn(GLsync sync, - GLbitfield flags, - GLuint64 timeout) { - return GL_TRUE; -} - } // namespace gl diff --git a/chromium/ui/gl/gl_stub_api.h b/chromium/ui/gl/gl_stub_api.h index 4c9f8ad2d64..01bd331346f 100644 --- a/chromium/ui/gl/gl_stub_api.h +++ b/chromium/ui/gl/gl_stub_api.h @@ -70,9 +70,6 @@ class GL_EXPORT GLStubApi: public GLStubApiBase { GLboolean glTestFenceAPPLEFn(GLuint fence) override; GLboolean glTestFenceNVFn(GLuint fence) override; GLboolean glUnmapBufferFn(GLenum target) override; - GLenum glWaitSyncFn(GLsync sync, - GLbitfield flags, - GLuint64 timeout) override; private: std::string version_; diff --git a/chromium/ui/gl/gl_stub_autogen_gl.cc b/chromium/ui/gl/gl_stub_autogen_gl.cc index 95f664301f6..e30dbfd7eaf 100644 --- a/chromium/ui/gl/gl_stub_autogen_gl.cc +++ b/chromium/ui/gl/gl_stub_autogen_gl.cc @@ -164,10 +164,4 @@ GLboolean GLStubApiBase::glUnmapBufferFn(GLenum target) { return 0; } -GLenum GLStubApiBase::glWaitSyncFn(GLsync sync, - GLbitfield flags, - GLuint64 timeout) { - return 0; -} - } // namespace gl diff --git a/chromium/ui/gl/gl_stub_autogen_gl.h b/chromium/ui/gl/gl_stub_autogen_gl.h index e14d946a831..c0097ebf94e 100644 --- a/chromium/ui/gl/gl_stub_autogen_gl.h +++ b/chromium/ui/gl/gl_stub_autogen_gl.h @@ -531,6 +531,7 @@ void glGetInternalformativRobustANGLEFn(GLenum target, GLsizei bufSize, GLsizei* length, GLint* params) override {} +void glGetMultisamplefvFn(GLenum pname, GLuint index, GLfloat* val) override {} void glGetMultisamplefvRobustANGLEFn(GLenum pname, GLuint index, GLsizei bufSize, @@ -873,6 +874,7 @@ void glPathStencilFuncNVFn(GLenum func, GLint ref, GLuint mask) override {} void glPauseTransformFeedbackFn() override {} void glPixelStoreiFn(GLenum pname, GLint param) override {} void glPointParameteriFn(GLenum pname, GLint param) override {} +void glPolygonModeFn(GLenum face, GLenum mode) override {} void glPolygonOffsetFn(GLfloat factor, GLfloat units) override {} void glPopDebugGroupFn() override {} void glPopGroupMarkerEXTFn() override {} @@ -1055,6 +1057,14 @@ void glStencilThenCoverStrokePathNVFn(GLuint path, GLenum coverMode) override {} GLboolean glTestFenceAPPLEFn(GLuint fence) override; GLboolean glTestFenceNVFn(GLuint fence) override; +void glTexBufferFn(GLenum target, + GLenum internalformat, + GLuint buffer) override {} +void glTexBufferRangeFn(GLenum target, + GLenum internalformat, + GLuint buffer, + GLintptr offset, + GLsizeiptr size) override {} void glTexImage2DFn(GLenum target, GLint level, GLint internalformat, @@ -1292,4 +1302,4 @@ void glVertexAttribPointerFn(GLuint indx, GLsizei stride, const void* ptr) override {} void glViewportFn(GLint x, GLint y, GLsizei width, GLsizei height) override {} -GLenum glWaitSyncFn(GLsync sync, GLbitfield flags, GLuint64 timeout) override; +void glWaitSyncFn(GLsync sync, GLbitfield flags, GLuint64 timeout) override {} diff --git a/chromium/ui/gl/gl_surface.cc b/chromium/ui/gl/gl_surface.cc index 67671902974..7ed029bb8f7 100644 --- a/chromium/ui/gl/gl_surface.cc +++ b/chromium/ui/gl/gl_surface.cc @@ -38,6 +38,7 @@ bool GLSurface::Initialize(GLSurfaceFormat format) { bool GLSurface::Resize(const gfx::Size& size, float scale_factor, + ColorSpace color_space, bool has_alpha) { NOTIMPLEMENTED(); return false; @@ -182,6 +183,10 @@ bool GLSurface::SupportsDCLayers() const { return false; } +bool GLSurface::UseOverlaysForVideo() const { + return false; +} + bool GLSurface::SetDrawRectangle(const gfx::Rect& rect) { return false; } @@ -238,8 +243,9 @@ void GLSurfaceAdapter::Destroy() { bool GLSurfaceAdapter::Resize(const gfx::Size& size, float scale_factor, + ColorSpace color_space, bool has_alpha) { - return surface_->Resize(size, scale_factor, has_alpha); + return surface_->Resize(size, scale_factor, color_space, has_alpha); } bool GLSurfaceAdapter::Recreate() { @@ -391,6 +397,10 @@ bool GLSurfaceAdapter::SupportsDCLayers() const { return surface_->SupportsDCLayers(); } +bool GLSurfaceAdapter::UseOverlaysForVideo() const { + return surface_->UseOverlaysForVideo(); +} + bool GLSurfaceAdapter::SetDrawRectangle(const gfx::Rect& rect) { return surface_->SetDrawRectangle(rect); } diff --git a/chromium/ui/gl/gl_surface.h b/chromium/ui/gl/gl_surface.h index 5261d7c3b0b..5bc78d8a6cd 100644 --- a/chromium/ui/gl/gl_surface.h +++ b/chromium/ui/gl/gl_surface.h @@ -57,8 +57,17 @@ class GL_EXPORT GLSurface : public base::RefCounted<GLSurface> { // Destroys the surface. virtual void Destroy() = 0; + // Color spaces that can be dynamically specified to the surface when resized. + enum class ColorSpace { + UNSPECIFIED, + SRGB, + DISPLAY_P3, + SCRGB_LINEAR, + }; + virtual bool Resize(const gfx::Size& size, float scale_factor, + ColorSpace color_space, bool has_alpha); // Recreate the surface without changing the size. @@ -213,6 +222,8 @@ class GL_EXPORT GLSurface : public base::RefCounted<GLSurface> { virtual bool SupportsDCLayers() const; + virtual bool UseOverlaysForVideo() const; + // Set the rectangle that will be drawn into on the surface. virtual bool SetDrawRectangle(const gfx::Rect& rect); @@ -254,6 +265,7 @@ class GL_EXPORT GLSurfaceAdapter : public GLSurface { void Destroy() override; bool Resize(const gfx::Size& size, float scale_factor, + ColorSpace color_space, bool has_alpha) override; bool Recreate() override; bool DeferDraws() override; @@ -298,6 +310,7 @@ class GL_EXPORT GLSurfaceAdapter : public GLSurface { bool FlipsVertically() const override; bool BuffersFlipped() const override; bool SupportsDCLayers() const override; + bool UseOverlaysForVideo() const override; bool SetDrawRectangle(const gfx::Rect& rect) override; gfx::Vector2d GetDrawOffset() const override; void WaitForSnapshotRendering() override; diff --git a/chromium/ui/gl/gl_surface_egl.cc b/chromium/ui/gl/gl_surface_egl.cc index e51132ae38f..17c46a68408 100644 --- a/chromium/ui/gl/gl_surface_egl.cc +++ b/chromium/ui/gl/gl_surface_egl.cc @@ -34,7 +34,7 @@ #include "ui/gl/scoped_make_current.h" #include "ui/gl/sync_control_vsync_provider.h" -#if defined(USE_X11) && !defined(OS_CHROMEOS) +#if defined(USE_X11) extern "C" { #include <X11/Xlib.h> #define Status int @@ -144,6 +144,9 @@ bool g_egl_context_priority_supported = false; bool g_egl_khr_colorspace = false; bool g_egl_ext_colorspace_display_p3 = false; bool g_use_direct_composition = false; +bool g_egl_robust_resource_init_supported = false; +bool g_egl_display_texture_share_group_supported = false; +bool g_egl_create_context_client_arrays_supported = false; class EGLSyncControlVSyncProvider : public SyncControlVSyncProvider { public: @@ -204,7 +207,7 @@ EGLDisplay GetPlatformANGLEDisplay(EGLNativeDisplayType native_display, display_attribs.push_back(EGL_TRUE); } -#if defined(USE_X11) && !defined(OS_CHROMEOS) +#if defined(USE_X11) // ANGLE_NULL doesn't use the visual, and may run without X11 where we can't // get it anyway. if (platform_type != EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE) { @@ -314,7 +317,7 @@ EGLConfig ChooseConfig(GLSurfaceFormat format, bool surfaceless) { EGLint stencil_size = format.GetStencilBits(); EGLint samples = format.GetSamples(); -#if defined(USE_X11) && !defined(OS_CHROMEOS) +#if defined(USE_X11) // If we're using ANGLE_NULL, we may not have a display, in which case we // can't use XVisualManager. if (g_native_display) { @@ -575,6 +578,11 @@ bool GLSurfaceEGL::InitializeOneOff(EGLNativeDisplayType native_display) { !base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kDisableDirectComposition); + g_egl_display_texture_share_group_supported = + HasEGLExtension("EGL_ANGLE_display_texture_share_group"); + g_egl_create_context_client_arrays_supported = + HasEGLExtension("EGL_ANGLE_create_context_client_arrays"); + // TODO(oetuaho@nvidia.com): Surfaceless is disabled on Android as a temporary // workaround, since code written for Android WebView takes different paths // based on whether GL surface objects have underlying EGL surface handles, @@ -603,14 +611,24 @@ bool GLSurfaceEGL::InitializeOneOff(EGLNativeDisplayType native_display) { } } #endif + initialized_ = true; + return true; +} + +// static +bool GLSurfaceEGL::InitializeExtensionSettingsOneOff() { + if (!initialized_) + return false; + g_driver_egl.UpdateConditionalExtensionBindings(); + g_egl_extensions = eglQueryString(g_display, EGL_EXTENSIONS); return true; } // static void GLSurfaceEGL::ShutdownOneOff() { - ResetANGLEPlatform(g_display); + angle::ResetPlatform(g_display); if (g_display != EGL_NO_DISPLAY) eglTerminate(g_display); @@ -625,6 +643,9 @@ void GLSurfaceEGL::ShutdownOneOff() { g_egl_surface_orientation_supported = false; g_use_direct_composition = false; g_egl_surfaceless_context_supported = false; + g_egl_robust_resource_init_supported = false; + g_egl_display_texture_share_group_supported = false; + g_egl_create_context_client_arrays_supported = false; initialized_ = false; } @@ -677,6 +698,18 @@ bool GLSurfaceEGL::IsDirectCompositionSupported() { return g_use_direct_composition; } +bool GLSurfaceEGL::IsRobustResourceInitSupported() { + return g_egl_robust_resource_init_supported; +} + +bool GLSurfaceEGL::IsDisplayTextureShareGroupSupported() { + return g_egl_display_texture_share_group_supported; +} + +bool GLSurfaceEGL::IsCreateContextClientArraysSupported() { + return g_egl_create_context_client_arrays_supported; +} + GLSurfaceEGL::~GLSurfaceEGL() {} // InitializeDisplay is necessary because the static binding code @@ -709,12 +742,12 @@ EGLDisplay GLSurfaceEGL::InitializeDisplay( ExtensionsContain(client_extensions, "EGL_ANGLE_platform_angle_null"); } - bool supports_robust_resource_init = + g_egl_robust_resource_init_supported = client_extensions && ExtensionsContain(client_extensions, "EGL_ANGLE_display_robust_resource_initialization"); bool use_robust_resource_init = - supports_robust_resource_init && + g_egl_robust_resource_init_supported && UsePassthroughCommandDecoder(base::CommandLine::ForCurrentProcess()); std::vector<DisplayType> init_displays; @@ -733,7 +766,7 @@ EGLDisplay GLSurfaceEGL::InitializeDisplay( // Init ANGLE platform now that we have the global display. if (supports_angle_d3d || supports_angle_opengl || supports_angle_null) { - if (!InitializeANGLEPlatform(display)) { + if (!angle::InitializePlatform(display)) { LOG(ERROR) << "ANGLE Platform initialization failed."; } } @@ -941,6 +974,7 @@ gfx::Size NativeViewGLSurfaceEGL::GetSize() { bool NativeViewGLSurfaceEGL::Resize(const gfx::Size& size, float scale_factor, + ColorSpace color_space, bool has_alpha) { if (size == GetSize()) return true; @@ -1177,6 +1211,7 @@ gfx::Size PbufferGLSurfaceEGL::GetSize() { bool PbufferGLSurfaceEGL::Resize(const gfx::Size& size, float scale_factor, + ColorSpace color_space, bool has_alpha) { if (size == size_) return true; @@ -1260,6 +1295,7 @@ gfx::Size SurfacelessEGL::GetSize() { bool SurfacelessEGL::Resize(const gfx::Size& size, float scale_factor, + ColorSpace color_space, bool has_alpha) { size_ = size; return true; diff --git a/chromium/ui/gl/gl_surface_egl.h b/chromium/ui/gl/gl_surface_egl.h index 779b5a6bfb8..042bf077d21 100644 --- a/chromium/ui/gl/gl_surface_egl.h +++ b/chromium/ui/gl/gl_surface_egl.h @@ -58,6 +58,7 @@ class GL_EXPORT GLSurfaceEGL : public GLSurface { GLSurfaceFormat GetFormat() override; static bool InitializeOneOff(EGLNativeDisplayType native_display); + static bool InitializeExtensionSettingsOneOff(); static void ShutdownOneOff(); static EGLDisplay GetHardwareDisplay(); static EGLDisplay InitializeDisplay(EGLNativeDisplayType native_display); @@ -74,6 +75,9 @@ class GL_EXPORT GLSurfaceEGL : public GLSurface { static bool IsEGLSurfacelessContextSupported(); static bool IsEGLContextPrioritySupported(); static bool IsDirectCompositionSupported(); + static bool IsRobustResourceInitSupported(); + static bool IsDisplayTextureShareGroupSupported(); + static bool IsCreateContextClientArraysSupported(); protected: ~GLSurfaceEGL() override; @@ -98,6 +102,7 @@ class GL_EXPORT NativeViewGLSurfaceEGL : public GLSurfaceEGL { void Destroy() override; bool Resize(const gfx::Size& size, float scale_factor, + ColorSpace color_space, bool has_alpha) override; bool Recreate() override; bool IsOffscreen() override; @@ -160,6 +165,7 @@ class GL_EXPORT PbufferGLSurfaceEGL : public GLSurfaceEGL { gfx::Size GetSize() override; bool Resize(const gfx::Size& size, float scale_factor, + ColorSpace color_space, bool has_alpha) override; EGLSurface GetHandle() override; void* GetShareHandle() override; @@ -190,6 +196,7 @@ class GL_EXPORT SurfacelessEGL : public GLSurfaceEGL { gfx::Size GetSize() override; bool Resize(const gfx::Size& size, float scale_factor, + ColorSpace color_space, bool has_alpha) override; EGLSurface GetHandle() override; void* GetShareHandle() override; diff --git a/chromium/ui/gl/gl_surface_egl_unittest.cc b/chromium/ui/gl/gl_surface_egl_unittest.cc index 2bb9057e131..5d2dad9c0a5 100644 --- a/chromium/ui/gl/gl_surface_egl_unittest.cc +++ b/chromium/ui/gl/gl_surface_egl_unittest.cc @@ -77,7 +77,7 @@ TEST(GLSurfaceEGLTest, FixedSizeExtension) { EXPECT_EQ(window_size, surface->GetSize()); gfx::Size resize_size(200, 300); - surface->Resize(resize_size, 1.0, false); + surface->Resize(resize_size, 1.0, GLSurface::ColorSpace::UNSPECIFIED, false); EXPECT_EQ(resize_size, surface->GetSize()); } diff --git a/chromium/ui/gl/gl_surface_egl_x11.cc b/chromium/ui/gl/gl_surface_egl_x11.cc index a72b45bf0dc..4d0cd09010e 100644 --- a/chromium/ui/gl/gl_surface_egl_x11.cc +++ b/chromium/ui/gl/gl_surface_egl_x11.cc @@ -144,6 +144,7 @@ EGLConfig NativeViewGLSurfaceEGLX11::GetConfig() { bool NativeViewGLSurfaceEGLX11::Resize(const gfx::Size& size, float scale_factor, + ColorSpace color_space, bool has_alpha) { if (size == GetSize()) return true; diff --git a/chromium/ui/gl/gl_surface_egl_x11.h b/chromium/ui/gl/gl_surface_egl_x11.h index f84ba41cab1..999d5b7ae79 100644 --- a/chromium/ui/gl/gl_surface_egl_x11.h +++ b/chromium/ui/gl/gl_surface_egl_x11.h @@ -27,6 +27,7 @@ class GL_EXPORT NativeViewGLSurfaceEGLX11 : public NativeViewGLSurfaceEGL, void Destroy() override; bool Resize(const gfx::Size& size, float scale_factor, + ColorSpace color_space, bool has_alpha) override; bool InitializeNativeWindow() override; diff --git a/chromium/ui/gl/gl_surface_glx.cc b/chromium/ui/gl/gl_surface_glx.cc index 4c0afc9d2c1..c656c109161 100644 --- a/chromium/ui/gl/gl_surface_glx.cc +++ b/chromium/ui/gl/gl_surface_glx.cc @@ -383,25 +383,31 @@ GLXContext SGIVideoSyncProviderThreadShim::context_ = 0; } // namespace +bool GLSurfaceGLX::initialized_ = false; + GLSurfaceGLX::GLSurfaceGLX() {} bool GLSurfaceGLX::InitializeOneOff() { - static bool initialized = false; - if (initialized) + if (initialized_) return true; // http://crbug.com/245466 setenv("force_s3tc_enable", "true", 1); + { + // As a hack to avoid sandbox threading violation on certain NVidia drivers, + // this block of code needs to be put before gfx::InitializeThreadedX11(). + // See crbug.com/756885. + g_display = gfx::GetXDisplay(); + if (!g_display) { + LOG(ERROR) << "XOpenDisplay failed."; + return false; + } + glXQueryExtensionsString(g_display, 0); + } // SGIVideoSyncProviderShim (if instantiated) will issue X commands on // it's own thread. gfx::InitializeThreadedX11(); - g_display = gfx::GetXDisplay(); - - if (!g_display) { - LOG(ERROR) << "XOpenDisplay failed."; - return false; - } int major, minor; if (!glXQueryVersion(g_display, &major, &minor)) { @@ -414,21 +420,6 @@ bool GLSurfaceGLX::InitializeOneOff() { return false; } - g_glx_context_create = HasGLXExtension("GLX_ARB_create_context"); - g_glx_create_context_robustness_supported = - HasGLXExtension("GLX_ARB_create_context_robustness"); - g_glx_create_context_profile_supported = - HasGLXExtension("GLX_ARB_create_context_profile"); - g_glx_create_context_profile_es2_supported = - HasGLXExtension("GLX_ARB_create_context_es2_profile"); - g_glx_texture_from_pixmap_supported = - HasGLXExtension("GLX_EXT_texture_from_pixmap"); - g_glx_oml_sync_control_supported = HasGLXExtension("GLX_OML_sync_control"); - g_glx_get_msc_rate_oml_supported = g_glx_oml_sync_control_supported; - g_glx_ext_swap_control_supported = HasGLXExtension("GLX_EXT_swap_control"); - g_glx_mesa_swap_control_supported = HasGLXExtension("GLX_MESA_swap_control"); - g_glx_sgi_video_sync_supported = HasGLXExtension("GLX_SGI_video_sync"); - const XVisualInfo& visual_info = gl::GLVisualPickerGLX::GetInstance()->system_visual(); g_visual = visual_info.visual; @@ -447,6 +438,32 @@ bool GLSurfaceGLX::InitializeOneOff() { return false; } + initialized_ = true; + return true; +} + +// static +bool GLSurfaceGLX::InitializeExtensionSettingsOneOff() { + if (!initialized_) + return false; + + g_driver_glx.InitializeExtensionBindings(); + + g_glx_context_create = HasGLXExtension("GLX_ARB_create_context"); + g_glx_create_context_robustness_supported = + HasGLXExtension("GLX_ARB_create_context_robustness"); + g_glx_create_context_profile_supported = + HasGLXExtension("GLX_ARB_create_context_profile"); + g_glx_create_context_profile_es2_supported = + HasGLXExtension("GLX_ARB_create_context_es2_profile"); + g_glx_texture_from_pixmap_supported = + HasGLXExtension("GLX_EXT_texture_from_pixmap"); + g_glx_oml_sync_control_supported = HasGLXExtension("GLX_OML_sync_control"); + g_glx_get_msc_rate_oml_supported = g_glx_oml_sync_control_supported; + g_glx_ext_swap_control_supported = HasGLXExtension("GLX_EXT_swap_control"); + g_glx_mesa_swap_control_supported = HasGLXExtension("GLX_MESA_swap_control"); + g_glx_sgi_video_sync_supported = HasGLXExtension("GLX_SGI_video_sync"); + if (!g_glx_get_msc_rate_oml_supported && g_glx_sgi_video_sync_supported) { Display* video_sync_display = gfx::OpenNewXDisplay(); if (!CreateDummyWindow(video_sync_display)) { @@ -455,8 +472,6 @@ bool GLSurfaceGLX::InitializeOneOff() { } SGIVideoSyncProviderThreadShim::display_ = video_sync_display; } - - initialized = true; return true; } @@ -592,6 +607,7 @@ void NativeViewGLSurfaceGLX::Destroy() { bool NativeViewGLSurfaceGLX::Resize(const gfx::Size& size, float scale_factor, + ColorSpace color_space, bool has_alpha) { size_ = size; glXWaitGL(); diff --git a/chromium/ui/gl/gl_surface_glx.h b/chromium/ui/gl/gl_surface_glx.h index 10a213c9010..e67ed7ed132 100644 --- a/chromium/ui/gl/gl_surface_glx.h +++ b/chromium/ui/gl/gl_surface_glx.h @@ -27,6 +27,7 @@ class GL_EXPORT GLSurfaceGLX : public GLSurface { GLSurfaceGLX(); static bool InitializeOneOff(); + static bool InitializeExtensionSettingsOneOff(); // These aren't particularly tied to surfaces, but since we already // have the static InitializeOneOff here, it's easiest to reuse its @@ -55,6 +56,7 @@ class GL_EXPORT GLSurfaceGLX : public GLSurface { private: DISALLOW_COPY_AND_ASSIGN(GLSurfaceGLX); + static bool initialized_; }; // A surface used to render to a view. @@ -67,6 +69,7 @@ class GL_EXPORT NativeViewGLSurfaceGLX : public GLSurfaceGLX { void Destroy() override; bool Resize(const gfx::Size& size, float scale_factor, + ColorSpace color_space, bool has_alpha) override; bool IsOffscreen() override; gfx::SwapResult SwapBuffers() override; diff --git a/chromium/ui/gl/gl_surface_osmesa.cc b/chromium/ui/gl/gl_surface_osmesa.cc index 741f535696f..fd0347107e2 100644 --- a/chromium/ui/gl/gl_surface_osmesa.cc +++ b/chromium/ui/gl/gl_surface_osmesa.cc @@ -26,7 +26,7 @@ GLSurfaceOSMesa::GLSurfaceOSMesa(GLSurfaceFormat format, } bool GLSurfaceOSMesa::Initialize(GLSurfaceFormat format) { - return Resize(size_, 1.f, true); + return Resize(size_, 1.f, ColorSpace::UNSPECIFIED, true); } void GLSurfaceOSMesa::Destroy() { @@ -35,6 +35,7 @@ void GLSurfaceOSMesa::Destroy() { bool GLSurfaceOSMesa::Resize(const gfx::Size& new_size, float scale_factor, + ColorSpace color_space, bool has_alpha) { std::unique_ptr<ui::ScopedMakeCurrent> scoped_make_current; GLContext* current_context = GLContext::GetCurrent(); diff --git a/chromium/ui/gl/gl_surface_osmesa.h b/chromium/ui/gl/gl_surface_osmesa.h index 55e92957806..246bc2922e3 100644 --- a/chromium/ui/gl/gl_surface_osmesa.h +++ b/chromium/ui/gl/gl_surface_osmesa.h @@ -28,6 +28,7 @@ class GL_EXPORT GLSurfaceOSMesa : public GLSurface { void Destroy() override; bool Resize(const gfx::Size& new_size, float scale_factor, + ColorSpace color_space, bool has_alpha) override; bool IsOffscreen() override; gfx::SwapResult SwapBuffers() override; diff --git a/chromium/ui/gl/gl_surface_osmesa_x11.cc b/chromium/ui/gl/gl_surface_osmesa_x11.cc index 62141cdfae2..988d3c600a8 100644 --- a/chromium/ui/gl/gl_surface_osmesa_x11.cc +++ b/chromium/ui/gl/gl_surface_osmesa_x11.cc @@ -78,8 +78,9 @@ void GLSurfaceOSMesaX11::Destroy() { bool GLSurfaceOSMesaX11::Resize(const gfx::Size& new_size, float scale_factor, + ColorSpace color_space, bool alpha) { - if (!GLSurfaceOSMesa::Resize(new_size, scale_factor, alpha)) + if (!GLSurfaceOSMesa::Resize(new_size, scale_factor, color_space, alpha)) return false; XWindowAttributes attributes; diff --git a/chromium/ui/gl/gl_surface_osmesa_x11.h b/chromium/ui/gl/gl_surface_osmesa_x11.h index 96072c7f844..e51fbc8791e 100644 --- a/chromium/ui/gl/gl_surface_osmesa_x11.h +++ b/chromium/ui/gl/gl_surface_osmesa_x11.h @@ -28,6 +28,7 @@ class GL_EXPORT GLSurfaceOSMesaX11 : public GLSurfaceOSMesa { void Destroy() override; bool Resize(const gfx::Size& new_size, float scale_factor, + ColorSpace color_space, bool alpha) override; bool IsOffscreen() override; gfx::SwapResult SwapBuffers() override; diff --git a/chromium/ui/gl/gl_surface_stub.cc b/chromium/ui/gl/gl_surface_stub.cc index 6f93fa8c058..af66724a8c4 100644 --- a/chromium/ui/gl/gl_surface_stub.cc +++ b/chromium/ui/gl/gl_surface_stub.cc @@ -11,6 +11,7 @@ void GLSurfaceStub::Destroy() { bool GLSurfaceStub::Resize(const gfx::Size& size, float scale_factor, + ColorSpace color_space, bool has_alpha) { return true; } diff --git a/chromium/ui/gl/gl_surface_stub.h b/chromium/ui/gl/gl_surface_stub.h index 7e11a9dfbae..c6fe52f8bbe 100644 --- a/chromium/ui/gl/gl_surface_stub.h +++ b/chromium/ui/gl/gl_surface_stub.h @@ -24,6 +24,7 @@ class GL_EXPORT GLSurfaceStub : public GLSurface { void Destroy() override; bool Resize(const gfx::Size& size, float scale_factor, + ColorSpace color_space, bool has_alpha) override; bool IsOffscreen() override; gfx::SwapResult SwapBuffers() override; diff --git a/chromium/ui/gl/gl_surface_wgl.cc b/chromium/ui/gl/gl_surface_wgl.cc index eb48cc462e4..65b64a161ca 100644 --- a/chromium/ui/gl/gl_surface_wgl.cc +++ b/chromium/ui/gl/gl_surface_wgl.cc @@ -148,6 +148,9 @@ class DisplayWGL { DisplayWGL* g_display; } // namespace +// static +bool GLSurfaceWGL::initialized_ = false; + GLSurfaceWGL::GLSurfaceWGL() { } @@ -158,9 +161,9 @@ void* GLSurfaceWGL::GetDisplay() { return GetDisplayDC(); } +// static bool GLSurfaceWGL::InitializeOneOff() { - static bool initialized = false; - if (initialized) + if (initialized_) return true; DCHECK(g_display == NULL); @@ -169,7 +172,15 @@ bool GLSurfaceWGL::InitializeOneOff() { return false; g_display = wgl_display.release(); - initialized = true; + initialized_ = true; + return true; +} + +// static +bool GLSurfaceWGL::InitializeExtensionSettingsOneOff() { + if (!initialized_) + return false; + g_driver_wgl.InitializeExtensionBindings(); return true; } @@ -257,6 +268,7 @@ void NativeViewGLSurfaceWGL::Destroy() { bool NativeViewGLSurfaceWGL::Resize(const gfx::Size& size, float scale_factor, + ColorSpace color_space, bool has_alpha) { RECT rect; if (!GetClientRect(window_, &rect)) { diff --git a/chromium/ui/gl/gl_surface_wgl.h b/chromium/ui/gl/gl_surface_wgl.h index 1396f059cef..ee4a67fc7d4 100644 --- a/chromium/ui/gl/gl_surface_wgl.h +++ b/chromium/ui/gl/gl_surface_wgl.h @@ -21,6 +21,7 @@ class GL_EXPORT GLSurfaceWGL : public GLSurface { void* GetDisplay() override; static bool InitializeOneOff(); + static bool InitializeExtensionSettingsOneOff(); static void InitializeOneOffForTesting(); static HDC GetDisplayDC(); @@ -29,6 +30,7 @@ class GL_EXPORT GLSurfaceWGL : public GLSurface { private: DISALLOW_COPY_AND_ASSIGN(GLSurfaceWGL); + static bool initialized_; }; // A surface used to render to a view. @@ -41,6 +43,7 @@ class GL_EXPORT NativeViewGLSurfaceWGL : public GLSurfaceWGL { void Destroy() override; bool Resize(const gfx::Size& size, float scale_factor, + ColorSpace color_space, bool has_alpha) override; bool Recreate() override; bool IsOffscreen() override; diff --git a/chromium/ui/gl/gl_switches.cc b/chromium/ui/gl/gl_switches.cc index a09d9592b63..f34a0b7eff2 100644 --- a/chromium/ui/gl/gl_switches.cc +++ b/chromium/ui/gl/gl_switches.cc @@ -28,10 +28,6 @@ const char kANGLEImplementationNullName[] = "null"; namespace switches { -// Ask the GLX driver for the default context instead of trying to get the -// highest version possible. -const char kCreateDefaultGLContext[] = "create-default-gl-context"; - // Disables use of D3D11. const char kDisableD3D11[] = "disable-d3d11"; @@ -79,9 +75,6 @@ const char kGpuNoContextLost[] = "gpu-no-context-lost"; // Disables the use of DirectComposition to draw to the screen. const char kDisableDirectComposition[] = "disable-direct-composition"; -// Indicates whether the dual GPU switching is supported or not. -const char kSupportsDualGpus[] = "supports-dual-gpus"; - // Flag used for Linux tests: for desktop GL bindings, try to load this GL // library first, but fall back to regular library if loading fails. const char kTestGLLib[] = "test-gl-lib"; @@ -129,9 +122,10 @@ const char kUsePassthroughCmdDecoder[] = "use-passthrough-cmd-decoder"; // This is the list of switches passed from this file that are passed from the // GpuProcessHost to the GPU Process. Add your switch to this list if you need // to read it in the GPU process, else don't add it. -const char* kGLSwitchesCopiedFromGpuProcessHost[] = { +const char* const kGLSwitchesCopiedFromGpuProcessHost[] = { kDisableGpuVsync, kDisableD3D11, + kDisableES3GLContext, kEnableGPUServiceLogging, kEnableGPUServiceTracing, kEnableSgiVideoSync, @@ -139,7 +133,6 @@ const char* kGLSwitchesCopiedFromGpuProcessHost[] = { kDisableGLDrawingForTests, kOverrideUseSoftwareGLForTests, kUseANGLE, - kDisableDirectComposition, kEnableSwapBuffersWithBounds, kEnableDirectCompositionLayers, kDisableDirectCompositionLayers, @@ -169,4 +162,8 @@ const base::Feature kDirectCompositionUnderlays{ const base::Feature kDirectCompositionComplexOverlays{ "DirectCompositionComplexOverlays", base::FEATURE_DISABLED_BY_DEFAULT}; +// Allow using overlays for non-root render passes. +const base::Feature kDirectCompositionNonrootOverlays{ + "DirectCompositionNonrootOverlays", base::FEATURE_DISABLED_BY_DEFAULT}; + } // namespace features diff --git a/chromium/ui/gl/gl_switches.h b/chromium/ui/gl/gl_switches.h index 04d3bc7be57..75a8a24e03b 100644 --- a/chromium/ui/gl/gl_switches.h +++ b/chromium/ui/gl/gl_switches.h @@ -34,7 +34,6 @@ GL_EXPORT extern const char kANGLEImplementationNullName[]; namespace switches { -GL_EXPORT extern const char kCreateDefaultGLContext[]; GL_EXPORT extern const char kDisableD3D11[]; GL_EXPORT extern const char kDisableES3GLContext[]; GL_EXPORT extern const char kDisableGpuVsync[]; @@ -43,8 +42,6 @@ GL_EXPORT extern const char kEnableGPUServiceTracing[]; GL_EXPORT extern const char kGpuNoContextLost[]; GL_EXPORT extern const char kDisableDirectComposition[]; -GL_EXPORT extern const char kSupportsDualGpus[]; - GL_EXPORT extern const char kUseANGLE[]; GL_EXPORT extern const char kUseGL[]; GL_EXPORT extern const char kTestGLLib[]; @@ -63,7 +60,7 @@ GL_EXPORT extern const char kUsePassthroughCmdDecoder[]; GL_EXPORT extern const char kDisableGLDrawingForTests[]; GL_EXPORT extern const char kOverrideUseSoftwareGLForTests[]; -GL_EXPORT extern const char* kGLSwitchesCopiedFromGpuProcessHost[]; +GL_EXPORT extern const char* const kGLSwitchesCopiedFromGpuProcessHost[]; GL_EXPORT extern const int kGLSwitchesCopiedFromGpuProcessHostNumSwitches; } // namespace switches @@ -76,6 +73,7 @@ GL_EXPORT extern const base::Feature kD3DVsync; GL_EXPORT extern const base::Feature kDirectCompositionUnderlays; GL_EXPORT extern const base::Feature kDirectCompositionComplexOverlays; +GL_EXPORT extern const base::Feature kDirectCompositionNonrootOverlays; } // namespace features diff --git a/chromium/ui/gl/gl_utils.cc b/chromium/ui/gl/gl_utils.cc index a1ac0693d14..3cc2e6336d1 100644 --- a/chromium/ui/gl/gl_utils.cc +++ b/chromium/ui/gl/gl_utils.cc @@ -6,6 +6,8 @@ #include "ui/gl/gl_utils.h" +#include "ui/gfx/color_space.h" +#include "ui/gl/gl_bindings.h" #include "ui/gl/gl_switches.h" namespace gl { @@ -13,4 +15,10 @@ namespace gl { bool UsePassthroughCommandDecoder(const base::CommandLine* command_line) { return command_line->HasSwitch(switches::kUsePassthroughCmdDecoder); } + +int GetGLColorSpace(const gfx::ColorSpace& color_space) { + if (color_space == gfx::ColorSpace::CreateSCRGBLinear()) + return GL_COLOR_SPACE_SCRGB_LINEAR_CHROMIUM; + return GL_COLOR_SPACE_UNSPECIFIED_CHROMIUM; +} } diff --git a/chromium/ui/gl/gl_utils.h b/chromium/ui/gl/gl_utils.h index db0bf3a9b52..7a362fe2991 100644 --- a/chromium/ui/gl/gl_utils.h +++ b/chromium/ui/gl/gl_utils.h @@ -10,9 +10,15 @@ #include "base/command_line.h" #include "ui/gl/gl_export.h" +namespace gfx { +class ColorSpace; +} // namespace gfx + namespace gl { GL_EXPORT bool UsePassthroughCommandDecoder( const base::CommandLine* command_line); -} + +GL_EXPORT int GetGLColorSpace(const gfx::ColorSpace& color_space); +} // namespace gl #endif // UI_GL_GL_UTILS_H_ diff --git a/chromium/ui/gl/gl_version_info.cc b/chromium/ui/gl/gl_version_info.cc index 5bf6a7f406b..9e1b1cc0492 100644 --- a/chromium/ui/gl/gl_version_info.cc +++ b/chromium/ui/gl/gl_version_info.cc @@ -24,25 +24,7 @@ namespace gl { GLVersionInfo::GLVersionInfo(const char* version_str, const char* renderer_str, - const char* extensions_str) - : GLVersionInfo() { - std::set<std::string> extensions; - if (extensions_str) { - auto split = base::SplitString(extensions_str, " ", base::KEEP_WHITESPACE, - base::SPLIT_WANT_NONEMPTY); - extensions.insert(split.begin(), split.end()); - } - Initialize(version_str, renderer_str, extensions); -} - -GLVersionInfo::GLVersionInfo(const char* version_str, - const char* renderer_str, - const std::set<std::string>& extensions) - : GLVersionInfo() { - Initialize(version_str, renderer_str, extensions); -} - -GLVersionInfo::GLVersionInfo() + const ExtensionSet& extensions) : is_es(false), is_angle(false), is_mesa(false), @@ -52,11 +34,13 @@ GLVersionInfo::GLVersionInfo() is_es2(false), is_es3(false), is_desktop_core_profile(false), - is_es3_capable(false) {} + is_es3_capable(false) { + Initialize(version_str, renderer_str, extensions); +} void GLVersionInfo::Initialize(const char* version_str, const char* renderer_str, - const std::set<std::string>& extensions) { + const ExtensionSet& extensions) { if (version_str) { ParseVersionString(version_str, &major_version, &minor_version, &is_es, &is_es2, &is_es3); @@ -71,16 +55,11 @@ void GLVersionInfo::Initialize(const char* version_str, } is_desktop_core_profile = DesktopCoreCommonCheck(is_es, major_version, minor_version) && - extensions.find("GL_ARB_compatibility") == extensions.end(); + !HasExtension(extensions, "GL_ARB_compatibility"); is_es3_capable = IsES3Capable(extensions); } -bool GLVersionInfo::IsES3Capable( - const std::set<std::string>& extensions) const { - auto has_extension = [&extensions](std::string extension) -> bool { - return extensions.find(extension) != extensions.end(); - }; - +bool GLVersionInfo::IsES3Capable(const ExtensionSet& extensions) const { // Version ES3 capable without extensions needed. if (IsAtLeastGLES(3, 0) || IsAtLeastGL(4, 2)) { return true; @@ -92,7 +71,8 @@ bool GLVersionInfo::IsES3Capable( } bool has_transform_feedback = - (IsAtLeastGL(4, 0) || has_extension("GL_ARB_transform_feedback2")); + (IsAtLeastGL(4, 0) || + HasExtension(extensions, "GL_ARB_transform_feedback2")); // This code used to require the GL_ARB_gpu_shader5 extension in order to // have support for dynamic indexing of sampler arrays, which was @@ -101,7 +81,7 @@ bool GLVersionInfo::IsES3Capable( // Mesa/Gallium on AMD GPUs) don't support it, we no longer require it. // tex storage is available in core spec since GL 4.2. - bool has_tex_storage = has_extension("GL_ARB_texture_storage"); + bool has_tex_storage = HasExtension(extensions, "GL_ARB_texture_storage"); // TODO(cwallez) check for texture related extensions. See crbug.com/623577 diff --git a/chromium/ui/gl/gl_version_info.h b/chromium/ui/gl/gl_version_info.h index 1775716c33b..a0278fbcfed 100644 --- a/chromium/ui/gl/gl_version_info.h +++ b/chromium/ui/gl/gl_version_info.h @@ -9,16 +9,15 @@ #include <string> #include "base/macros.h" #include "build/build_config.h" +#include "ui/gl/extension_set.h" #include "ui/gl/gl_export.h" namespace gl { struct GL_EXPORT GLVersionInfo { - GLVersionInfo(const char* version_str, const char* renderer_str, - const char* extensions_str); - - GLVersionInfo(const char* version_str, const char* renderer_str, - const std::set<std::string>& exts); + GLVersionInfo(const char* version_str, + const char* renderer_str, + const ExtensionSet& exts); bool IsAtLeastGL(unsigned major, unsigned minor) const { return !is_es && (major_version > major || @@ -62,11 +61,10 @@ struct GL_EXPORT GLVersionInfo { bool is_es3_capable; private: - GLVersionInfo(); void Initialize(const char* version_str, const char* renderer_str, - const std::set<std::string>& extensions); - bool IsES3Capable(const std::set<std::string>& extensions) const; + const ExtensionSet& extensions); + bool IsES3Capable(const ExtensionSet& extensions) const; DISALLOW_COPY_AND_ASSIGN(GLVersionInfo); }; diff --git a/chromium/ui/gl/gl_version_info_unittest.cc b/chromium/ui/gl/gl_version_info_unittest.cc index 2463e0eef00..fed30da954e 100644 --- a/chromium/ui/gl/gl_version_info_unittest.cc +++ b/chromium/ui/gl/gl_version_info_unittest.cc @@ -15,14 +15,13 @@ TEST(GLVersionInfoTest, MajorMinorVersionTest) { "OpenGL ES 2.0 (ANGLE 2.1.0.cd1b12260360)", "2.1 INTEL-10.6.33"}; const char* renderer_str[] = {NULL, NULL, NULL, NULL}; - const char* extensions_str[] = {"extensions", "extensions", - "extensions", "extensions"}; + ExtensionSet extensions = {"extensions"}; unsigned expected_major[] = {4, 4, 2, 2}; unsigned expected_minor[] = {3, 5, 0, 1}; std::unique_ptr<GLVersionInfo> version_info; for (unsigned i = 0; i < arraysize(version_str); i++) { - version_info.reset(new GLVersionInfo(version_str[i], - renderer_str[i], extensions_str[i])); + version_info.reset( + new GLVersionInfo(version_str[i], renderer_str[i], extensions)); unsigned major, minor; bool is_es, is_es2, is_es3; version_info->ParseVersionString(version_str[i], &major, &minor, diff --git a/chromium/ui/gl/gl_wgl_api_implementation.cc b/chromium/ui/gl/gl_wgl_api_implementation.cc index c6a500fc6d8..7cda14ed652 100644 --- a/chromium/ui/gl/gl_wgl_api_implementation.cc +++ b/chromium/ui/gl/gl_wgl_api_implementation.cc @@ -7,7 +7,9 @@ #include "base/command_line.h" #include "base/strings/string_split.h" #include "base/strings/string_util.h" +#include "ui/gl/gl_context.h" #include "ui/gl/gl_implementation.h" +#include "ui/gl/gl_surface_wgl.h" namespace gl { @@ -21,7 +23,6 @@ void InitializeStaticGLBindingsWGL() { } g_real_wgl->Initialize(&g_driver_wgl); g_current_wgl_context = g_real_wgl; - g_driver_wgl.InitializeExtensionBindings(); } void InitializeDebugGLBindingsWGL() { @@ -68,16 +69,10 @@ RealWGLApi::~RealWGLApi() { } void RealWGLApi::Initialize(DriverWGL* driver) { - InitializeWithCommandLine(driver, base::CommandLine::ForCurrentProcess()); -} - -void RealWGLApi::InitializeWithCommandLine(DriverWGL* driver, - base::CommandLine* command_line) { - DCHECK(command_line); InitializeBase(driver); +} - const std::string disabled_extensions = command_line->GetSwitchValueASCII( - switches::kDisableGLExtensions); +void RealWGLApi::SetDisabledExtensions(const std::string& disabled_extensions) { disabled_exts_.clear(); filtered_ext_exts_ = ""; filtered_arb_exts_ = ""; @@ -123,9 +118,23 @@ DebugWGLApi::DebugWGLApi(WGLApi* wgl_api) : wgl_api_(wgl_api) {} DebugWGLApi::~DebugWGLApi() {} +void DebugWGLApi::SetDisabledExtensions( + const std::string& disabled_extensions) { + if (wgl_api_) { + wgl_api_->SetDisabledExtensions(disabled_extensions); + } +} + TraceWGLApi::~TraceWGLApi() { } +void TraceWGLApi::SetDisabledExtensions( + const std::string& disabled_extensions) { + if (wgl_api_) { + wgl_api_->SetDisabledExtensions(disabled_extensions); + } +} + bool GetGLWindowSystemBindingInfoWGL(GLWindowSystemBindingInfo* info) { const char* extensions = wglGetExtensionsStringEXT(); *info = GLWindowSystemBindingInfo(); @@ -134,4 +143,14 @@ bool GetGLWindowSystemBindingInfoWGL(GLWindowSystemBindingInfo* info) { return true; } +void SetDisabledExtensionsWGL(const std::string& disabled_extensions) { + DCHECK(g_current_wgl_context); + DCHECK(GLContext::TotalGLContexts() == 0); + g_current_wgl_context->SetDisabledExtensions(disabled_extensions); +} + +bool InitializeExtensionSettingsOneOffWGL() { + return GLSurfaceWGL::InitializeExtensionSettingsOneOff(); +} + } // namespace gl diff --git a/chromium/ui/gl/gl_wgl_api_implementation.h b/chromium/ui/gl/gl_wgl_api_implementation.h index cc3628c15df..8db7ab42c6d 100644 --- a/chromium/ui/gl/gl_wgl_api_implementation.h +++ b/chromium/ui/gl/gl_wgl_api_implementation.h @@ -5,15 +5,13 @@ #ifndef UI_GL_GL_WGL_API_IMPLEMENTATION_H_ #define UI_GL_GL_WGL_API_IMPLEMENTATION_H_ +#include <string> #include <vector> #include "base/compiler_specific.h" #include "ui/gl/gl_bindings.h" #include "ui/gl/gl_export.h" -namespace base { -class CommandLine; -} namespace gl { struct GLWindowSystemBindingInfo; @@ -22,6 +20,8 @@ GL_EXPORT void InitializeStaticGLBindingsWGL(); GL_EXPORT void InitializeDebugGLBindingsWGL(); GL_EXPORT void ClearBindingsWGL(); GL_EXPORT bool GetGLWindowSystemBindingInfoWGL(GLWindowSystemBindingInfo* info); +GL_EXPORT void SetDisabledExtensionsWGL(const std::string& disabled_extensions); +GL_EXPORT bool InitializeExtensionSettingsOneOffWGL(); class GL_EXPORT WGLApiBase : public WGLApi { public: @@ -43,8 +43,7 @@ class GL_EXPORT RealWGLApi : public WGLApiBase { RealWGLApi(); ~RealWGLApi() override; void Initialize(DriverWGL* driver); - void InitializeWithCommandLine(DriverWGL* driver, - base::CommandLine* command_line); + void SetDisabledExtensions(const std::string& disabled_extensions) override; const char* wglGetExtensionsStringARBFn(HDC hDC) override; const char* wglGetExtensionsStringEXTFn() override; @@ -60,6 +59,7 @@ class GL_EXPORT DebugWGLApi : public WGLApi { public: DebugWGLApi(WGLApi* wgl_api); ~DebugWGLApi() override; + void SetDisabledExtensions(const std::string& disabled_extensions) override; // Include the auto-generated part of this class. We split this because // it means we can easily edit the non-auto generated parts right here in @@ -75,6 +75,7 @@ class GL_EXPORT TraceWGLApi : public WGLApi { public: TraceWGLApi(WGLApi* wgl_api) : wgl_api_(wgl_api) { } ~TraceWGLApi() override; + void SetDisabledExtensions(const std::string& disabled_extensions) override; // Include the auto-generated part of this class. We split this because // it means we can easily edit the non-auto generated parts right here in @@ -88,6 +89,3 @@ class GL_EXPORT TraceWGLApi : public WGLApi { } // namespace gl #endif // UI_GL_GL_WGL_API_IMPLEMENTATION_H_ - - - diff --git a/chromium/ui/gl/gl_workarounds.h b/chromium/ui/gl/gl_workarounds.h index 2b93214209a..8660dba058b 100644 --- a/chromium/ui/gl/gl_workarounds.h +++ b/chromium/ui/gl/gl_workarounds.h @@ -11,6 +11,9 @@ struct GLWorkarounds { // glClearColor does not always work on Intel 6xxx Mac drivers. See // crbug.com/710443. bool clear_to_zero_or_one_broken = false; + // Reset texImage2D base level to workaround pixel comparison failure + // above Mac OS 10.12.4 on Intel Mac. See crbug.com/705865. + bool reset_teximage2d_base_level = false; }; } // namespace gl diff --git a/chromium/ui/gl/glx_api_unittest.cc b/chromium/ui/gl/glx_api_unittest.cc index c36c7259228..1b2dfc9fc7f 100644 --- a/chromium/ui/gl/glx_api_unittest.cc +++ b/chromium/ui/gl/glx_api_unittest.cc @@ -4,7 +4,6 @@ #include <memory> -#include "base/command_line.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/gl/gl_glx_api_implementation.h" #include "ui/gl/gl_implementation.h" @@ -31,13 +30,13 @@ class GLXApiTest : public testing::Test { fake_extension_string_ = ""; } - void InitializeAPI(base::CommandLine* command_line) { + void InitializeAPI(const char* disabled_extensions) { api_.reset(new RealGLXApi()); g_current_glx_context = api_.get(); - if (command_line) - api_->InitializeWithCommandLine(&g_driver_glx, command_line); - else - api_->Initialize(&g_driver_glx); + api_->Initialize(&g_driver_glx); + if (disabled_extensions) { + SetDisabledExtensionsGLX(disabled_extensions); + } g_driver_glx.InitializeExtensionBindings(); } @@ -88,10 +87,7 @@ TEST_F(GLXApiTest, DisabledExtensionBitTest) { EXPECT_TRUE(g_driver_glx.ext.b_GLX_ARB_create_context); - base::CommandLine command_line(base::CommandLine::NO_PROGRAM); - command_line.AppendSwitchASCII(switches::kDisableGLExtensions, - kFakeDisabledExtensions); - InitializeAPI(&command_line); + InitializeAPI(kFakeDisabledExtensions); EXPECT_FALSE(g_driver_glx.ext.b_GLX_ARB_create_context); } @@ -108,10 +104,7 @@ TEST_F(GLXApiTest, DisabledExtensionStringTest) { EXPECT_STREQ(kFakeExtensions, GetExtensions()); - base::CommandLine command_line(base::CommandLine::NO_PROGRAM); - command_line.AppendSwitchASCII(switches::kDisableGLExtensions, - kFakeDisabledExtensions); - InitializeAPI(&command_line); + InitializeAPI(kFakeDisabledExtensions); EXPECT_STREQ(kFilteredExtensions, GetExtensions()); } diff --git a/chromium/ui/gl/gpu_preference.h b/chromium/ui/gl/gpu_preference.h index 67abb755800..edfb679839b 100644 --- a/chromium/ui/gl/gpu_preference.h +++ b/chromium/ui/gl/gpu_preference.h @@ -15,6 +15,7 @@ namespace gl { // This API will likely need to be adjusted as the functionality is // implemented on more operating systems. enum GpuPreference { + GpuPreferenceNone, PreferIntegratedGpu, PreferDiscreteGpu, GpuPreferenceLast = PreferDiscreteGpu diff --git a/chromium/ui/gl/gpu_switching_manager.cc b/chromium/ui/gl/gpu_switching_manager.cc index 9718114c538..be715646580 100644 --- a/chromium/ui/gl/gpu_switching_manager.cc +++ b/chromium/ui/gl/gpu_switching_manager.cc @@ -4,120 +4,16 @@ #include "ui/gl/gpu_switching_manager.h" -#include "base/command_line.h" -#include "base/logging.h" -#include "build/build_config.h" -#include "ui/gl/gl_switches.h" - -#if defined(OS_MACOSX) -#include <OpenGL/OpenGL.h> -#include "ui/gl/gl_context_cgl.h" -#endif // OS_MACOSX - namespace ui { -struct GpuSwitchingManager::PlatformSpecific { -#if defined(OS_MACOSX) - CGLPixelFormatObj discrete_pixel_format; -#endif // OS_MACOSX -}; - // static GpuSwitchingManager* GpuSwitchingManager::GetInstance() { return base::Singleton<GpuSwitchingManager>::get(); } -GpuSwitchingManager::GpuSwitchingManager() - : gpu_switching_option_(gl::PreferIntegratedGpu), - gpu_switching_option_set_(false), - supports_dual_gpus_(false), - supports_dual_gpus_set_(false), - platform_specific_(new PlatformSpecific) { -#if defined(OS_MACOSX) - platform_specific_->discrete_pixel_format = nullptr; -#endif // OS_MACOSX -} - -GpuSwitchingManager::~GpuSwitchingManager() { -#if defined(OS_MACOSX) - if (platform_specific_->discrete_pixel_format) - CGLReleasePixelFormat(platform_specific_->discrete_pixel_format); -#endif // OS_MACOSX -} - -void GpuSwitchingManager::ForceUseOfIntegratedGpu() { - DCHECK(SupportsDualGpus()); - if (gpu_switching_option_set_) { - DCHECK_EQ(gpu_switching_option_, gl::PreferIntegratedGpu); - } else { - gpu_switching_option_ = gl::PreferIntegratedGpu; - gpu_switching_option_set_ = true; - } -} - -void GpuSwitchingManager::ForceUseOfDiscreteGpu() { - DCHECK(SupportsDualGpus()); - if (gpu_switching_option_set_) { - DCHECK_EQ(gpu_switching_option_, gl::PreferDiscreteGpu); - } else { - gpu_switching_option_ = gl::PreferDiscreteGpu; - gpu_switching_option_set_ = true; -#if defined(OS_MACOSX) - // Create a pixel format that lasts the lifespan of Chrome, so Chrome - // stays on the discrete GPU. - SwitchToDiscreteGpuMac(); -#endif // OS_MACOSX - } -} - -bool GpuSwitchingManager::SupportsDualGpus() { - if (!supports_dual_gpus_set_) { - const base::CommandLine& command_line = - *base::CommandLine::ForCurrentProcess(); - bool flag = false; - if (command_line.HasSwitch(switches::kSupportsDualGpus)) { - // GPU process, flag is passed down from browser process. - std::string flag_string = command_line.GetSwitchValueASCII( - switches::kSupportsDualGpus); - if (flag_string == "true") { - flag = true; - } else if (flag_string == "false") { - flag = false; - } else { - NOTIMPLEMENTED(); - } - } else { - // Browser process. - // We only compute this flag in the browser process. -#if defined(OS_MACOSX) - flag = (vendor_ids_.size() == 2); - if (flag && command_line.HasSwitch(switches::kUseGL) && - command_line.GetSwitchValueASCII(switches::kUseGL) != - gl::kGLImplementationDesktopName) - flag = false; +GpuSwitchingManager::GpuSwitchingManager() {} - if (flag) { - // Only advertise that we have two GPUs to the rest of - // Chrome's code if we find an Intel GPU and some other - // vendor's GPU. Otherwise we don't understand the - // configuration and don't deal well with it (an example being - // the dual AMD GPUs in recent Mac Pros). - const uint32_t intel = 0x8086; - flag = ((vendor_ids_[0] == intel && vendor_ids_[1] != intel) || - (vendor_ids_[0] != intel && vendor_ids_[1] == intel)); - } -#endif // OS_MACOSX - } - supports_dual_gpus_ = flag; - supports_dual_gpus_set_ = true; - } - return supports_dual_gpus_; -} - -void GpuSwitchingManager::SetGpuVendorIds( - const std::vector<uint32_t>& vendor_ids) { - vendor_ids_ = vendor_ids; -} +GpuSwitchingManager::~GpuSwitchingManager() {} void GpuSwitchingManager::AddObserver(GpuSwitchingObserver* observer) { observer_list_.AddObserver(observer); @@ -132,23 +28,4 @@ void GpuSwitchingManager::NotifyGpuSwitched() { observer.OnGpuSwitched(); } -gl::GpuPreference GpuSwitchingManager::AdjustGpuPreference( - gl::GpuPreference gpu_preference) { - if (!gpu_switching_option_set_) - return gpu_preference; - return gpu_switching_option_; -} - -#if defined(OS_MACOSX) -void GpuSwitchingManager::SwitchToDiscreteGpuMac() { - if (platform_specific_->discrete_pixel_format) - return; - CGLPixelFormatAttribute attribs[1]; - attribs[0] = static_cast<CGLPixelFormatAttribute>(0); - GLint num_pixel_formats = 0; - CGLChoosePixelFormat(attribs, &platform_specific_->discrete_pixel_format, - &num_pixel_formats); -} -#endif // OS_MACOSX - } // namespace ui diff --git a/chromium/ui/gl/gpu_switching_manager.h b/chromium/ui/gl/gpu_switching_manager.h index 4ac76200235..4308bbed939 100644 --- a/chromium/ui/gl/gpu_switching_manager.h +++ b/chromium/ui/gl/gpu_switching_manager.h @@ -5,17 +5,10 @@ #ifndef UI_GL_GPU_SWITCHING_MANAGER_H_ #define UI_GL_GPU_SWITCHING_MANAGER_H_ -#include <stdint.h> - -#include <memory> -#include <vector> - -#include "base/macros.h" #include "base/memory/singleton.h" #include "base/observer_list.h" #include "build/build_config.h" #include "ui/gl/gl_export.h" -#include "ui/gl/gpu_preference.h" #include "ui/gl/gpu_switching_observer.h" namespace ui { @@ -25,26 +18,6 @@ class GL_EXPORT GpuSwitchingManager { // Getter for the singleton. This will return NULL on failure. static GpuSwitchingManager* GetInstance(); - // Set the switching option to PreferIntegratedGpu. - void ForceUseOfIntegratedGpu(); - // Set the switching option to PreferDiscreteGpu; switch to discrete GPU - // immediately on Mac where dual GPU switching is supported. - void ForceUseOfDiscreteGpu(); - - // If no GPU is forced, return the original GpuPreference; otherwise, return - // the forced GPU. - gl::GpuPreference AdjustGpuPreference(gl::GpuPreference gpu_preference); - - // In the browser process, the value for this flag is computed the first time - // this function is called. - // In the GPU process, the value is passed from the browser process using the - // --supports-dual-gpus commandline switch. - bool SupportsDualGpus(); - - // Sets the vendor IDs of the GPUs on the system. The length of this - // vector defines the count of GPUs. - void SetGpuVendorIds(const std::vector<uint32_t>& vendor_ids); - void AddObserver(GpuSwitchingObserver* observer); void RemoveObserver(GpuSwitchingObserver* observer); @@ -61,21 +34,6 @@ class GL_EXPORT GpuSwitchingManager { GpuSwitchingManager(); virtual ~GpuSwitchingManager(); -#if defined(OS_MACOSX) - void SwitchToDiscreteGpuMac(); -#endif // OS_MACOSX - - gl::GpuPreference gpu_switching_option_; - bool gpu_switching_option_set_; - - std::vector<uint32_t> vendor_ids_; - - bool supports_dual_gpus_; - bool supports_dual_gpus_set_; - - struct PlatformSpecific; - std::unique_ptr<PlatformSpecific> platform_specific_; - base::ObserverList<GpuSwitchingObserver> observer_list_; DISALLOW_COPY_AND_ASSIGN(GpuSwitchingManager); diff --git a/chromium/ui/gl/init/BUILD.gn b/chromium/ui/gl/init/BUILD.gn index bd43b3eee78..dea64ed0c05 100644 --- a/chromium/ui/gl/init/BUILD.gn +++ b/chromium/ui/gl/init/BUILD.gn @@ -49,11 +49,6 @@ component("init") { ] libs = [ "OpenGL.framework" ] - } else if (is_fuchsia) { - sources += [ - "gl_factory_fuchsia.cc", - "gl_initializer_fuchsia.cc", - ] } else if (use_x11) { sources += [ "gl_factory_x11.cc", diff --git a/chromium/ui/gl/init/gl_factory.cc b/chromium/ui/gl/init/gl_factory.cc index 744b430d733..643941be273 100644 --- a/chromium/ui/gl/init/gl_factory.cc +++ b/chromium/ui/gl/init/gl_factory.cc @@ -17,9 +17,8 @@ namespace gl { namespace init { -bool InitializeGLOneOff() { - TRACE_EVENT0("gpu,startup", "gl::init::InitializeOneOff"); - +namespace { +bool InitializeGLOneOffHelper(bool init_extensions) { DCHECK_EQ(kGLImplementationNone, GetGLImplementation()); std::vector<GLImplementation> allowed_impls = GetAllowedGLImplementations(); @@ -56,14 +55,28 @@ bool InitializeGLOneOff() { bool gpu_service_logging = cmd->HasSwitch(switches::kEnableGPUServiceLogging); bool disable_gl_drawing = cmd->HasSwitch(switches::kDisableGLDrawingForTests); - return InitializeGLOneOffImplementation( - impl, fallback_to_software_gl, gpu_service_logging, disable_gl_drawing); + return InitializeGLOneOffImplementation(impl, fallback_to_software_gl, + gpu_service_logging, + disable_gl_drawing, init_extensions); +} + +} // namespace + +bool InitializeGLOneOff() { + TRACE_EVENT0("gpu,startup", "gl::init::InitializeOneOff"); + return InitializeGLOneOffHelper(true); +} + +bool InitializeGLNoExtensionsOneOff() { + TRACE_EVENT0("gpu,startup", "gl::init::InitializeNoExtensionsOneOff"); + return InitializeGLOneOffHelper(false); } bool InitializeGLOneOffImplementation(GLImplementation impl, bool fallback_to_software_gl, bool gpu_service_logging, - bool disable_gl_drawing) { + bool disable_gl_drawing, + bool init_extensions) { bool initialized = InitializeStaticGLBindings(impl) && InitializeGLOneOffPlatform(); if (!initialized && fallback_to_software_gl) { @@ -71,6 +84,10 @@ bool InitializeGLOneOffImplementation(GLImplementation impl, initialized = InitializeStaticGLBindings(GetSoftwareGLImplementation()) && InitializeGLOneOffPlatform(); } + if (initialized && init_extensions) { + initialized = InitializeExtensionSettingsOneOffPlatform(); + } + if (!initialized) ShutdownGL(); diff --git a/chromium/ui/gl/init/gl_factory.h b/chromium/ui/gl/init/gl_factory.h index 52dcbe1a074..44819daaca2 100644 --- a/chromium/ui/gl/init/gl_factory.h +++ b/chromium/ui/gl/init/gl_factory.h @@ -6,6 +6,7 @@ #define UI_GL_INIT_GL_FACTORY_H_ #include <memory> +#include <string> #include <vector> #include "base/memory/ref_counted.h" @@ -36,13 +37,21 @@ GL_INIT_EXPORT std::vector<GLImplementation> GetAllowedGLImplementations(); // Initializes GL bindings. GL_INIT_EXPORT bool InitializeGLOneOff(); +// Initializes GL bindings without initializing extension settings. +GL_INIT_EXPORT bool InitializeGLNoExtensionsOneOff(); + +// Initialize plaiform dependent extension settings, including bindings, +// capabilities, etc. +GL_INIT_EXPORT bool InitializeExtensionSettingsOneOffPlatform(); + // Initializes GL bindings using the provided parameters. This might be required // for use in tests, otherwise use InitializeGLOneOff() instead. GL_INIT_EXPORT bool InitializeGLOneOffImplementation( GLImplementation impl, bool fallback_to_software_gl, bool gpu_service_logging, - bool disable_gl_drawing); + bool disable_gl_drawing, + bool init_extensions); // Clears GL bindings and resets GL implementation. GL_INIT_EXPORT void ShutdownGL(); @@ -87,6 +96,11 @@ GL_INIT_EXPORT scoped_refptr<GLSurface> CreateOffscreenGLSurface( GL_INIT_EXPORT scoped_refptr<GLSurface> CreateOffscreenGLSurfaceWithFormat( const gfx::Size& size, GLSurfaceFormat format); +// Set platform dependent disabled extensions and re-initialize extension +// bindings. +GL_INIT_EXPORT void SetDisabledExtensionsPlatform( + const std::string& disabled_extensions); + } // namespace init } // namespace gl diff --git a/chromium/ui/gl/init/gl_factory_android.cc b/chromium/ui/gl/init/gl_factory_android.cc index dff62b16213..476c61730f6 100644 --- a/chromium/ui/gl/init/gl_factory_android.cc +++ b/chromium/ui/gl/init/gl_factory_android.cc @@ -39,7 +39,6 @@ class GLNonOwnedContext : public GLContextReal { bool IsCurrent(GLSurface* surface) override { return true; } void* GetHandle() override { return nullptr; } void OnSetSwapInterval(int interval) override {} - std::string GetExtensions() override; protected: ~GLNonOwnedContext() override {} @@ -66,14 +65,6 @@ bool GLNonOwnedContext::MakeCurrent(GLSurface* surface) { return true; } -std::string GLNonOwnedContext::GetExtensions() { - const char* extensions = eglQueryString(display_, EGL_EXTENSIONS); - if (!extensions) - return GLContext::GetExtensions(); - - return GLContext::GetExtensions() + " " + extensions; -} - } // namespace std::vector<GLImplementation> GetAllowedGLImplementations() { @@ -166,5 +157,37 @@ scoped_refptr<GLSurface> CreateOffscreenGLSurfaceWithFormat( } } +void SetDisabledExtensionsPlatform(const std::string& disabled_extensions) { + GLImplementation implementation = GetGLImplementation(); + DCHECK_NE(kGLImplementationNone, implementation); + switch (implementation) { + case kGLImplementationEGLGLES2: + SetDisabledExtensionsEGL(disabled_extensions); + break; + case kGLImplementationMockGL: + case kGLImplementationStubGL: + case kGLImplementationOSMesaGL: + break; + default: + NOTREACHED(); + } +} + +bool InitializeExtensionSettingsOneOffPlatform() { + GLImplementation implementation = GetGLImplementation(); + DCHECK_NE(kGLImplementationNone, implementation); + switch (implementation) { + case kGLImplementationEGLGLES2: + return InitializeExtensionSettingsOneOffEGL(); + case kGLImplementationMockGL: + case kGLImplementationStubGL: + case kGLImplementationOSMesaGL: + return true; + default: + NOTREACHED(); + return false; + } +} + } // namespace init } // namespace gl diff --git a/chromium/ui/gl/init/gl_factory_fuchsia.cc b/chromium/ui/gl/init/gl_factory_fuchsia.cc deleted file mode 100644 index 9ec54533292..00000000000 --- a/chromium/ui/gl/init/gl_factory_fuchsia.cc +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ui/gl/init/gl_factory.h" - -#include "ui/gl/gl_context.h" -#include "ui/gl/gl_surface.h" - -namespace gl { -namespace init { - -// TODO(fuchsia): Implement these functions. - -std::vector<GLImplementation> GetAllowedGLImplementations() { - NOTIMPLEMENTED(); - return std::vector<GLImplementation>(); -} - -bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) { - NOTIMPLEMENTED(); - return false; -} - -scoped_refptr<GLContext> CreateGLContext(GLShareGroup* share_group, - GLSurface* compatible_surface, - const GLContextAttribs& attribs) { - NOTIMPLEMENTED(); - return nullptr; -} - -scoped_refptr<GLSurface> CreateViewGLSurface(gfx::AcceleratedWidget window) { - NOTIMPLEMENTED(); - return nullptr; -} - -scoped_refptr<GLSurface> CreateOffscreenGLSurfaceWithFormat( - const gfx::Size& size, - GLSurfaceFormat format) { - NOTIMPLEMENTED(); - return nullptr; -} - -} // namespace init -} // namespace gl diff --git a/chromium/ui/gl/init/gl_factory_mac.cc b/chromium/ui/gl/init/gl_factory_mac.cc index 6716f4109df..2a34dbe549e 100644 --- a/chromium/ui/gl/init/gl_factory_mac.cc +++ b/chromium/ui/gl/init/gl_factory_mac.cc @@ -143,5 +143,18 @@ scoped_refptr<GLSurface> CreateOffscreenGLSurfaceWithFormat( } } +void SetDisabledExtensionsPlatform(const std::string& disabled_extensions) { + GLImplementation implementation = GetGLImplementation(); + DCHECK_NE(kGLImplementationNone, implementation); + // TODO(zmo): Implement this if needs arise. +} + +bool InitializeExtensionSettingsOneOffPlatform() { + GLImplementation implementation = GetGLImplementation(); + DCHECK_NE(kGLImplementationNone, implementation); + // TODO(zmo): Implement this if needs arise. + return true; +} + } // namespace init } // namespace gl diff --git a/chromium/ui/gl/init/gl_factory_ozone.cc b/chromium/ui/gl/init/gl_factory_ozone.cc index a4e0097cb20..cad4a4715ef 100644 --- a/chromium/ui/gl/init/gl_factory_ozone.cc +++ b/chromium/ui/gl/init/gl_factory_ozone.cc @@ -8,6 +8,7 @@ #include "base/trace_event/trace_event.h" #include "ui/gl/gl_context.h" #include "ui/gl/gl_context_stub.h" +#include "ui/gl/gl_egl_api_implementation.h" #include "ui/gl/gl_implementation.h" #include "ui/gl/gl_share_group.h" #include "ui/gl/gl_surface.h" @@ -104,5 +105,47 @@ scoped_refptr<GLSurface> CreateOffscreenGLSurfaceWithFormat( return nullptr; } +void SetDisabledExtensionsPlatform(const std::string& disabled_extensions) { + GLImplementation implementation = GetGLImplementation(); + DCHECK_NE(kGLImplementationNone, implementation); + switch (implementation) { + case kGLImplementationEGLGLES2: + SetDisabledExtensionsEGL(disabled_extensions); + break; + case kGLImplementationDesktopGL: + // TODO(zmo): I don't think ozone goes down this path except for testing. + // This might change in the future though. + break; + case kGLImplementationSwiftShaderGL: + case kGLImplementationOSMesaGL: + case kGLImplementationMockGL: + case kGLImplementationStubGL: + break; + default: + NOTREACHED(); + } +} + +bool InitializeExtensionSettingsOneOffPlatform() { + GLImplementation implementation = GetGLImplementation(); + DCHECK_NE(kGLImplementationNone, implementation); + switch (implementation) { + case kGLImplementationEGLGLES2: + return InitializeExtensionSettingsOneOffEGL(); + case kGLImplementationDesktopGL: + // TODO(zmo): I don't think ozone goes down this path except for testing. + // This might change in the future though. + return true; + case kGLImplementationSwiftShaderGL: + case kGLImplementationOSMesaGL: + case kGLImplementationMockGL: + case kGLImplementationStubGL: + return true; + default: + NOTREACHED(); + return false; + } +} + } // namespace init } // namespace gl diff --git a/chromium/ui/gl/init/gl_factory_win.cc b/chromium/ui/gl/init/gl_factory_win.cc index ca5b04b62f3..b9f442cd4e3 100644 --- a/chromium/ui/gl/init/gl_factory_win.cc +++ b/chromium/ui/gl/init/gl_factory_win.cc @@ -136,5 +136,44 @@ scoped_refptr<GLSurface> CreateOffscreenGLSurfaceWithFormat( } } +void SetDisabledExtensionsPlatform(const std::string& disabled_extensions) { + GLImplementation implementation = GetGLImplementation(); + DCHECK_NE(kGLImplementationNone, implementation); + switch (implementation) { + case kGLImplementationDesktopGL: + SetDisabledExtensionsWGL(disabled_extensions); + break; + case kGLImplementationEGLGLES2: + SetDisabledExtensionsEGL(disabled_extensions); + break; + case kGLImplementationSwiftShaderGL: + case kGLImplementationOSMesaGL: + case kGLImplementationMockGL: + case kGLImplementationStubGL: + break; + default: + NOTREACHED(); + } +} + +bool InitializeExtensionSettingsOneOffPlatform() { + GLImplementation implementation = GetGLImplementation(); + DCHECK_NE(kGLImplementationNone, implementation); + switch (implementation) { + case kGLImplementationDesktopGL: + return InitializeExtensionSettingsOneOffWGL(); + case kGLImplementationEGLGLES2: + return InitializeExtensionSettingsOneOffEGL(); + case kGLImplementationSwiftShaderGL: + case kGLImplementationOSMesaGL: + case kGLImplementationMockGL: + case kGLImplementationStubGL: + return true; + default: + NOTREACHED(); + return false; + } +} + } // namespace init } // namespace gl diff --git a/chromium/ui/gl/init/gl_factory_x11.cc b/chromium/ui/gl/init/gl_factory_x11.cc index 9b0f48174b0..b55fe76b197 100644 --- a/chromium/ui/gl/init/gl_factory_x11.cc +++ b/chromium/ui/gl/init/gl_factory_x11.cc @@ -124,5 +124,44 @@ scoped_refptr<GLSurface> CreateOffscreenGLSurfaceWithFormat( } } +void SetDisabledExtensionsPlatform(const std::string& disabled_extensions) { + GLImplementation implementation = GetGLImplementation(); + DCHECK_NE(kGLImplementationNone, implementation); + switch (implementation) { + case kGLImplementationDesktopGL: + SetDisabledExtensionsGLX(disabled_extensions); + break; + case kGLImplementationEGLGLES2: + SetDisabledExtensionsEGL(disabled_extensions); + break; + case kGLImplementationSwiftShaderGL: + case kGLImplementationOSMesaGL: + case kGLImplementationMockGL: + case kGLImplementationStubGL: + break; + default: + NOTREACHED(); + } +} + +bool InitializeExtensionSettingsOneOffPlatform() { + GLImplementation implementation = GetGLImplementation(); + DCHECK_NE(kGLImplementationNone, implementation); + switch (implementation) { + case kGLImplementationDesktopGL: + return InitializeExtensionSettingsOneOffGLX(); + case kGLImplementationEGLGLES2: + return InitializeExtensionSettingsOneOffEGL(); + case kGLImplementationSwiftShaderGL: + case kGLImplementationOSMesaGL: + case kGLImplementationMockGL: + case kGLImplementationStubGL: + return true; + default: + NOTREACHED(); + return false; + } +} + } // namespace init } // namespace gl diff --git a/chromium/ui/gl/init/gl_initializer_fuchsia.cc b/chromium/ui/gl/init/gl_initializer_fuchsia.cc deleted file mode 100644 index 73d543d5ebc..00000000000 --- a/chromium/ui/gl/init/gl_initializer_fuchsia.cc +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ui/gl/init/gl_initializer.h" - -namespace gl { -namespace init { - -// TODO(fuchsia): Implement these functions. - -bool InitializeGLOneOffPlatform() { - NOTIMPLEMENTED(); - return false; -} - -bool InitializeStaticGLBindings(GLImplementation implementation) { - NOTIMPLEMENTED(); - return false; -} - -void InitializeDebugGLBindings() { - NOTIMPLEMENTED(); -} - -void ShutdownGLPlatform() { - NOTIMPLEMENTED(); -} - -} // namespace init -} // namespace gl diff --git a/chromium/ui/gl/init/gl_initializer_mac.cc b/chromium/ui/gl/init/gl_initializer_mac.cc index a574fb9df48..828ce9bb013 100644 --- a/chromium/ui/gl/init/gl_initializer_mac.cc +++ b/chromium/ui/gl/init/gl_initializer_mac.cc @@ -16,6 +16,7 @@ #include "base/path_service.h" #include "base/threading/thread_restrictions.h" #include "ui/gl/gl_bindings.h" +#include "ui/gl/gl_context.h" #include "ui/gl/gl_gl_api_implementation.h" #include "ui/gl/gl_implementation.h" #include "ui/gl/gl_osmesa_api_implementation.h" @@ -39,7 +40,7 @@ bool InitializeOneOffForSandbox() { // GPU-related stuff is very slow without this, probably because // the sandbox prevents loading graphics drivers or some such. std::vector<CGLPixelFormatAttribute> attribs; - if (ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) { + if (GLContext::SwitchableGPUsSupported()) { // Avoid switching to the discrete GPU just for this pixel // format selection. attribs.push_back(kCGLPFAAllowOfflineRenderers); diff --git a/chromium/ui/gl/sync_control_vsync_provider.cc b/chromium/ui/gl/sync_control_vsync_provider.cc index f9dc5c56e47..d45840e8a65 100644 --- a/chromium/ui/gl/sync_control_vsync_provider.cc +++ b/chromium/ui/gl/sync_control_vsync_provider.cc @@ -40,8 +40,6 @@ void SyncControlVSyncProvider::GetVSyncParameters( const UpdateVSyncCallback& callback) { TRACE_EVENT0("gpu", "SyncControlVSyncProvider::GetVSyncParameters"); #if defined(OS_LINUX) - base::TimeTicks timebase; - // The actual clock used for the system time returned by glXGetSyncValuesOML // is unspecified. In practice, the clock used is likely to be either // CLOCK_REALTIME or CLOCK_MONOTONIC, so we compare the returned time to the @@ -67,16 +65,18 @@ void SyncControlVSyncProvider::GetVSyncParameters( } struct timespec real_time; - struct timespec monotonic_time; clock_gettime(CLOCK_REALTIME, &real_time); - clock_gettime(CLOCK_MONOTONIC, &monotonic_time); + // Note: A thread context switch could happen here, between the sampling of + // the two different clocks. + const base::TimeTicks monotonic_time = base::TimeTicks::Now(); + DCHECK_EQ(base::TimeTicks::GetClock(), + base::TimeTicks::Clock::LINUX_CLOCK_MONOTONIC); int64_t real_time_in_microseconds = real_time.tv_sec * base::Time::kMicrosecondsPerSecond + real_time.tv_nsec / base::Time::kNanosecondsPerMicrosecond; int64_t monotonic_time_in_microseconds = - monotonic_time.tv_sec * base::Time::kMicrosecondsPerSecond + - monotonic_time.tv_nsec / base::Time::kNanosecondsPerMicrosecond; + monotonic_time.since_origin().InMicroseconds(); // We need the time according to CLOCK_MONOTONIC, so if we've been given // a time from CLOCK_REALTIME, we need to convert. @@ -102,7 +102,8 @@ void SyncControlVSyncProvider::GetVSyncParameters( base::Time::kMicrosecondsPerSecond) return; - timebase = base::TimeTicks::FromInternalValue(system_time); + const base::TimeTicks timebase = + base::TimeTicks() + base::TimeDelta::FromMicroseconds(system_time); // Only need the previous calculated interval for our filtering. while (last_computed_intervals_.size() > 1) @@ -140,11 +141,10 @@ void SyncControlVSyncProvider::GetVSyncParameters( #else LOG(FATAL) #endif // USE_ASH - << "Calculated bogus refresh interval=" - << new_interval.InMicroseconds() - << " us., last_timebase_=" << last_timebase_.ToInternalValue() - << " us., timebase=" << timebase.ToInternalValue() - << " us., last_media_stream_counter_=" << last_media_stream_counter_ + << "Calculated bogus refresh interval=" << new_interval + << ", last_timebase_=" << last_timebase_ + << ", timebase=" << timebase + << ", last_media_stream_counter_=" << last_media_stream_counter_ << ", media_stream_counter=" << media_stream_counter; } else { last_good_interval_ = new_interval; diff --git a/chromium/ui/gl/vsync_provider_win.cc b/chromium/ui/gl/vsync_provider_win.cc index 8025ca9059a..b5c7c612ab7 100644 --- a/chromium/ui/gl/vsync_provider_win.cc +++ b/chromium/ui/gl/vsync_provider_win.cc @@ -105,7 +105,7 @@ void VSyncProviderWin::GetVSyncParameters(const UpdateVSyncCallback& callback) { } } - if (interval.ToInternalValue() != 0) { + if (!interval.is_zero()) { callback.Run(timebase, interval); } } diff --git a/chromium/ui/gl/wgl_api_unittest.cc b/chromium/ui/gl/wgl_api_unittest.cc index 041d3dfaf9f..a0fe216ffba 100644 --- a/chromium/ui/gl/wgl_api_unittest.cc +++ b/chromium/ui/gl/wgl_api_unittest.cc @@ -37,13 +37,13 @@ class WGLApiTest : public testing::Test { fake_arb_extension_string_ = ""; } - void InitializeAPI(base::CommandLine* command_line) { + void InitializeAPI(const char* disabled_extensions) { api_.reset(new RealWGLApi()); g_current_wgl_context = api_.get(); - if (command_line) - api_->InitializeWithCommandLine(&g_driver_wgl, command_line); - else - api_->Initialize(&g_driver_wgl); + api_->Initialize(&g_driver_wgl); + if (disabled_extensions) { + SetDisabledExtensionsWGL(disabled_extensions); + } g_driver_wgl.InitializeExtensionBindings(); } @@ -94,18 +94,14 @@ TEST_F(WGLApiTest, DisabledExtensionBitTest) { EXPECT_FALSE(g_driver_wgl.ext.b_WGL_ARB_extensions_string); - base::CommandLine command_line(base::CommandLine::NO_PROGRAM); - command_line.AppendSwitchASCII(switches::kDisableGLExtensions, - kFakeDisabledExtensions); - // NULL simulates not being able to resolve wglGetExtensionsStringARB - SetFakeARBExtensionString(NULL); + SetFakeARBExtensionString(nullptr); SetFakeEXTExtensionString(kFakeExtensions); InitializeAPI(nullptr); EXPECT_TRUE(g_driver_wgl.ext.b_WGL_ARB_extensions_string); - InitializeAPI(&command_line); + InitializeAPI(kFakeExtensions); EXPECT_FALSE(g_driver_wgl.ext.b_WGL_ARB_extensions_string); SetFakeARBExtensionString(""); @@ -123,7 +119,7 @@ TEST_F(WGLApiTest, DisabledExtensionBitTest) { InitializeAPI(nullptr); EXPECT_TRUE(g_driver_wgl.ext.b_WGL_ARB_extensions_string); - InitializeAPI(&command_line); + InitializeAPI(kFakeDisabledExtensions); EXPECT_FALSE(g_driver_wgl.ext.b_WGL_ARB_extensions_string); } @@ -134,10 +130,6 @@ TEST_F(WGLApiTest, DisabledExtensionStringTest) { "EGL_EXT_1,EGL_EXT_2,EGL_FAKE"; static const char* kFilteredExtensions = "EGL_EXT_3 EGL_EXT_4"; - base::CommandLine command_line(base::CommandLine::NO_PROGRAM); - command_line.AppendSwitchASCII(switches::kDisableGLExtensions, - kFakeDisabledExtensions); - SetFakeARBExtensionString(kFakeExtensions); SetFakeEXTExtensionString(kFakeExtensions); @@ -145,7 +137,7 @@ TEST_F(WGLApiTest, DisabledExtensionStringTest) { EXPECT_EQ(stringpair(kFakeExtensions, kFakeExtensions), GetExtensions()); - InitializeAPI(&command_line); + InitializeAPI(kFakeDisabledExtensions); EXPECT_EQ(stringpair(kFilteredExtensions, kFilteredExtensions), GetExtensions()); } diff --git a/chromium/ui/gl/yuv_to_rgb_converter.cc b/chromium/ui/gl/yuv_to_rgb_converter.cc index daef3990fbc..73410cb1c04 100644 --- a/chromium/ui/gl/yuv_to_rgb_converter.cc +++ b/chromium/ui/gl/yuv_to_rgb_converter.cc @@ -6,6 +6,7 @@ #include "base/strings/stringize_macros.h" #include "base/strings/stringprintf.h" +#include "ui/gfx/color_transform.h" #include "ui/gl/gl_helper.h" #include "ui/gl/gl_version_info.h" #include "ui/gl/scoped_binders.h" @@ -55,21 +56,25 @@ STRINGIZE( uniform sampler2DRect a_uv_texture; VARYING vec2 v_texCoord; void main() { - vec3 yuv_adj = vec3(-0.0625, -0.5, -0.5); - mat3 yuv_matrix = mat3(vec3(1.164, 1.164, 1.164), - vec3(0.0, -.391, 2.018), - vec3(1.596, -.813, 0.0)); vec3 yuv = vec3( TEX(a_y_texture, v_texCoord).r, TEX(a_uv_texture, v_texCoord * 0.5).rg); - FRAGCOLOR = vec4(yuv_matrix * (yuv + yuv_adj), 1.0); + FRAGCOLOR = vec4(DoColorConversion(yuv), 1.0); } ); // clang-format on } // namespace -YUVToRGBConverter::YUVToRGBConverter(const GLVersionInfo& gl_version_info) { +YUVToRGBConverter::YUVToRGBConverter(const GLVersionInfo& gl_version_info, + const gfx::ColorSpace color_space) { + std::unique_ptr<gfx::ColorTransform> color_transform = + gfx::ColorTransform::NewColorTransform( + color_space, color_space.GetAsFullRangeRGB(), + gfx::ColorTransform::Intent::INTENT_PERCEPTUAL); + DCHECK(color_transform->CanGetShaderSource()); + std::string do_color_conversion = color_transform->GetShaderSource(); + bool use_core_profile = gl_version_info.is_desktop_core_profile; glGenFramebuffersEXT(1, &framebuffer_); vertex_buffer_ = GLHelper::SetupQuadVertexBuffer(); @@ -82,10 +87,10 @@ YUVToRGBConverter::YUVToRGBConverter(const GLVersionInfo& gl_version_info) { .c_str()); fragment_shader_ = GLHelper::LoadShader( GL_FRAGMENT_SHADER, - base::StringPrintf("%s\n%s", + base::StringPrintf("%s\n%s\n%s", use_core_profile ? kFragmentHeaderCoreProfile : kFragmentHeaderCompatiblityProfile, - kFragmentShader) + do_color_conversion.c_str(), kFragmentShader) .c_str()); program_ = GLHelper::SetupProgram(vertex_shader_, fragment_shader_); diff --git a/chromium/ui/gl/yuv_to_rgb_converter.h b/chromium/ui/gl/yuv_to_rgb_converter.h index 7d9f8222589..94fbf6a2edb 100644 --- a/chromium/ui/gl/yuv_to_rgb_converter.h +++ b/chromium/ui/gl/yuv_to_rgb_converter.h @@ -7,13 +7,18 @@ #include "ui/gfx/geometry/size.h" +namespace gfx { +class ColorSpace; +} // namespace gfx + namespace gl { struct GLVersionInfo; class YUVToRGBConverter { public: - explicit YUVToRGBConverter(const GLVersionInfo& gl_version_info); + explicit YUVToRGBConverter(const GLVersionInfo& gl_version_info, + const gfx::ColorSpace color_space); ~YUVToRGBConverter(); // The input Y and UV textures should be bound to these texture objects |