Commit cfe2a03c authored by Maksim Sisov's avatar Maksim Sisov Committed by Commit Bot

X11 and Ozone: fix use_x11 && use_ozone build for gl

When use_x11 && use_ozone are set to true at the same
time, compiler throws an error about multiple definitions
of the gl_factory and gl_initializer.

Thus, to fix that, make X11 use ozone's definition of the
gl_factory and the gl_initializer and add a check for
usage of the OzonePlatform that will be used in the future
when use_x11 && use_ozone are both set.

Please note that it's impossible to build use_x11 && use_ozone without
some hacks in PlatformCursor code. The changes to that are on their
way to upstream.

Bug: 1085700
Change-Id: Icc4d54c0910627c90869a7c41e3e709021d77b4f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2247639
Commit-Queue: Maksim Sisov <msisov@igalia.com>
Reviewed-by: default avatarRobert Kroeger <rjkroege@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarZhenyao Mo <zmo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#780020}
parent c1c3ec91
...@@ -56,12 +56,36 @@ jumbo_component("init") { ...@@ -56,12 +56,36 @@ jumbo_component("init") {
] ]
libs = [ "OpenGL.framework" ] libs = [ "OpenGL.framework" ]
} else if (use_x11) { } else if (use_ozone) {
sources += [
"gl_display_egl_util_ozone.cc",
"gl_display_egl_util_ozone.h",
"ozone_util.h",
]
deps += [ "//ui/ozone" ]
}
# Allow X11 to use Ozone implementation of gl_factory and gl_initializer.
# This is needed temporarily to allow use_x11 && use_ozone build. Once
# use_x11 goes away, this will be removed. Internally, it checks whether
# it should use pure X11 implementation or Ozone implementation based on
# IsUsingOzonePlatform feature flag.
if (use_x11 || use_ozone) {
sources += [
"gl_factory_ozone.cc",
"gl_initializer_ozone.cc",
]
deps += [ "//ui/base:features" ]
}
if (use_x11) {
sources += [ sources += [
"gl_display_egl_util_x11.cc", "gl_display_egl_util_x11.cc",
"gl_display_egl_util_x11.h", "gl_display_egl_util_x11.h",
"gl_factory_x11.cc", "gl_factory_linux_x11.cc",
"gl_initializer_x11.cc", "gl_factory_linux_x11.h",
"gl_initializer_linux_x11.cc",
"gl_initializer_linux_x11.h",
] ]
deps += [ deps += [
...@@ -69,15 +93,5 @@ jumbo_component("init") { ...@@ -69,15 +93,5 @@ jumbo_component("init") {
"//ui/base/x:gl", "//ui/base/x:gl",
"//ui/gfx/x", "//ui/gfx/x",
] ]
} else if (use_ozone) {
sources += [
"gl_display_egl_util_ozone.cc",
"gl_display_egl_util_ozone.h",
"gl_factory_ozone.cc",
"gl_initializer_ozone.cc",
"ozone_util.h",
]
deps += [ "//ui/ozone" ]
} }
} }
include_rules = [ include_rules = [
"+ui/base/ui_base_features.h",
"+ui/ozone/gl", "+ui/ozone/gl",
"+ui/ozone/public", "+ui/ozone/public",
] ]
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ui/gl/init/gl_factory.h" #include "ui/gl/init/gl_factory_linux_x11.h"
#include "base/trace_event/trace_event.h" #include "base/trace_event/trace_event.h"
#include "ui/gl/gl_context.h" #include "ui/gl/gl_context.h"
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
namespace gl { namespace gl {
namespace init { namespace init {
std::vector<GLImplementation> GetAllowedGLImplementations() { std::vector<GLImplementation> GetAllowedGLImplementationsX11() {
std::vector<GLImplementation> impls; std::vector<GLImplementation> impls;
impls.push_back(kGLImplementationDesktopGL); impls.push_back(kGLImplementationDesktopGL);
impls.push_back(kGLImplementationEGLGLES2); impls.push_back(kGLImplementationEGLGLES2);
...@@ -32,8 +32,8 @@ std::vector<GLImplementation> GetAllowedGLImplementations() { ...@@ -32,8 +32,8 @@ std::vector<GLImplementation> GetAllowedGLImplementations() {
return impls; return impls;
} }
bool GetGLWindowSystemBindingInfo(const GLVersionInfo& gl_info, bool GetGLWindowSystemBindingInfoX11(const GLVersionInfo& gl_info,
GLWindowSystemBindingInfo* info) { GLWindowSystemBindingInfo* info) {
switch (GetGLImplementation()) { switch (GetGLImplementation()) {
case kGLImplementationDesktopGL: case kGLImplementationDesktopGL:
return GetGLWindowSystemBindingInfoGLX(gl_info, info); return GetGLWindowSystemBindingInfoGLX(gl_info, info);
...@@ -45,9 +45,9 @@ bool GetGLWindowSystemBindingInfo(const GLVersionInfo& gl_info, ...@@ -45,9 +45,9 @@ bool GetGLWindowSystemBindingInfo(const GLVersionInfo& gl_info,
} }
} }
scoped_refptr<GLContext> CreateGLContext(GLShareGroup* share_group, scoped_refptr<GLContext> CreateGLContextX11(GLShareGroup* share_group,
GLSurface* compatible_surface, GLSurface* compatible_surface,
const GLContextAttribs& attribs) { const GLContextAttribs& attribs) {
TRACE_EVENT0("gpu", "gl::init::CreateGLContext"); TRACE_EVENT0("gpu", "gl::init::CreateGLContext");
switch (GetGLImplementation()) { switch (GetGLImplementation()) {
case kGLImplementationDesktopGL: case kGLImplementationDesktopGL:
...@@ -72,7 +72,7 @@ scoped_refptr<GLContext> CreateGLContext(GLShareGroup* share_group, ...@@ -72,7 +72,7 @@ scoped_refptr<GLContext> CreateGLContext(GLShareGroup* share_group,
} }
} }
scoped_refptr<GLSurface> CreateViewGLSurface(gfx::AcceleratedWidget window) { scoped_refptr<GLSurface> CreateViewGLSurfaceX11(gfx::AcceleratedWidget window) {
TRACE_EVENT0("gpu", "gl::init::CreateViewGLSurface"); TRACE_EVENT0("gpu", "gl::init::CreateViewGLSurface");
switch (GetGLImplementation()) { switch (GetGLImplementation()) {
case kGLImplementationDesktopGL: case kGLImplementationDesktopGL:
...@@ -93,8 +93,9 @@ scoped_refptr<GLSurface> CreateViewGLSurface(gfx::AcceleratedWidget window) { ...@@ -93,8 +93,9 @@ scoped_refptr<GLSurface> CreateViewGLSurface(gfx::AcceleratedWidget window) {
} }
} }
scoped_refptr<GLSurface> CreateOffscreenGLSurfaceWithFormat( scoped_refptr<GLSurface> CreateOffscreenGLSurfaceWithFormatX11(
const gfx::Size& size, GLSurfaceFormat format) { const gfx::Size& size,
GLSurfaceFormat format) {
TRACE_EVENT0("gpu", "gl::init::CreateOffscreenGLSurface"); TRACE_EVENT0("gpu", "gl::init::CreateOffscreenGLSurface");
switch (GetGLImplementation()) { switch (GetGLImplementation()) {
case kGLImplementationDesktopGL: case kGLImplementationDesktopGL:
...@@ -119,7 +120,7 @@ scoped_refptr<GLSurface> CreateOffscreenGLSurfaceWithFormat( ...@@ -119,7 +120,7 @@ scoped_refptr<GLSurface> CreateOffscreenGLSurfaceWithFormat(
} }
} }
void SetDisabledExtensionsPlatform(const std::string& disabled_extensions) { void SetDisabledExtensionsPlatformX11(const std::string& disabled_extensions) {
GLImplementation implementation = GetGLImplementation(); GLImplementation implementation = GetGLImplementation();
DCHECK_NE(kGLImplementationNone, implementation); DCHECK_NE(kGLImplementationNone, implementation);
switch (implementation) { switch (implementation) {
...@@ -139,7 +140,7 @@ void SetDisabledExtensionsPlatform(const std::string& disabled_extensions) { ...@@ -139,7 +140,7 @@ void SetDisabledExtensionsPlatform(const std::string& disabled_extensions) {
} }
} }
bool InitializeExtensionSettingsOneOffPlatform() { bool InitializeExtensionSettingsOneOffPlatformX11() {
GLImplementation implementation = GetGLImplementation(); GLImplementation implementation = GetGLImplementation();
DCHECK_NE(kGLImplementationNone, implementation); DCHECK_NE(kGLImplementationNone, implementation);
switch (implementation) { switch (implementation) {
......
// Copyright 2020 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_INIT_GL_FACTORY_LINUX_X11_H_
#define UI_GL_INIT_GL_FACTORY_LINUX_X11_H_
#include <memory>
#include <string>
#include <vector>
#include "base/memory/ref_counted.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface_format.h"
#include "ui/gl/gpu_preference.h"
namespace gl {
class GLContext;
class GLShareGroup;
class GLSurface;
struct GLContextAttribs;
struct GLVersionInfo;
// Note that this is a temporary implementation for Linux/X11 GL. It is called
// through GLFactoryOzone, and will be removed as soon as Linux/Ozone is
// the default. Comments have been copied from gl_factory.h
//
// TODO(msisov): remove this once Ozone is the default on Linux.
namespace init {
// Returns a list of allowed GL implementations. The default implementation will
// be the first item.
std::vector<GLImplementation> GetAllowedGLImplementationsX11();
// Initializes GL bindings and extension settings.
bool InitializeGLOneOffX11();
// Initializes GL bindings without initializing extension settings.
bool InitializeGLNoExtensionsOneOffX11(bool init_bindings);
// Initializes GL bindings - load dlls and get proc address according to gl
// command line switch.
bool InitializeStaticGLBindingsOneOffX11();
// Initialize plaiform dependent extension settings, including bindings,
// capabilities, etc.
bool InitializeExtensionSettingsOneOffPlatformX11();
// Initializes GL bindings using the provided parameters. This might be required
// for use in tests.
bool InitializeStaticGLBindingsImplementationX11(GLImplementation impl,
bool fallback_to_software_gl);
// Initializes GL platform using the provided parameters. This might be required
// for use in tests. This should be called only after GL bindings are initilzed
// successfully.
bool InitializeGLOneOffPlatformImplementationX11(bool fallback_to_software_gl,
bool disable_gl_drawing,
bool init_extensions);
// Clears GL bindings and resets GL implementation.
void ShutdownGLX11(bool due_to_fallback);
// Return information about the GL window system binding implementation (e.g.,
// EGL, GLX, WGL). Returns true if the information was retrieved successfully.
bool GetGLWindowSystemBindingInfoX11(const GLVersionInfo& gl_info,
GLWindowSystemBindingInfo* info);
// Creates a GL context that is compatible with the given surface.
// |share_group|, if non-null, is a group of contexts which the internally
// created OpenGL context shares textures and other resources.
scoped_refptr<GLContext> CreateGLContextX11(GLShareGroup* share_group,
GLSurface* compatible_surface,
const GLContextAttribs& attribs);
// Creates a GL surface that renders directly to a view.
scoped_refptr<GLSurface> CreateViewGLSurfaceX11(gfx::AcceleratedWidget window);
// Creates a GL surface used for offscreen rendering.
scoped_refptr<GLSurface> CreateOffscreenGLSurfaceX11(const gfx::Size& size);
scoped_refptr<GLSurface> CreateOffscreenGLSurfaceWithFormatX11(
const gfx::Size& size,
GLSurfaceFormat format);
// Set platform dependent disabled extensions and re-initialize extension
// bindings.
void SetDisabledExtensionsPlatformX11(const std::string& disabled_extensions);
} // namespace init
} // namespace gl
#endif // UI_GL_INIT_GL_FACTORY_LINUX_X11_H_
...@@ -14,20 +14,45 @@ ...@@ -14,20 +14,45 @@
#include "ui/gl/gl_share_group.h" #include "ui/gl/gl_share_group.h"
#include "ui/gl/gl_surface.h" #include "ui/gl/gl_surface.h"
#include "ui/gl/gl_surface_stub.h" #include "ui/gl/gl_surface_stub.h"
#if defined(USE_OZONE)
#include "ui/gl/init/ozone_util.h" #include "ui/gl/init/ozone_util.h"
#endif
#if defined(USE_X11)
#include "ui/base/ui_base_features.h"
#include "ui/gl/init/gl_factory_linux_x11.h"
#endif
namespace gl { namespace gl {
namespace init { namespace init {
std::vector<GLImplementation> GetAllowedGLImplementations() { std::vector<GLImplementation> GetAllowedGLImplementations() {
#if defined(USE_X11)
if (!features::IsUsingOzonePlatform())
return gl::init::GetAllowedGLImplementationsX11();
#endif
#if defined(USE_OZONE)
DCHECK(GetSurfaceFactoryOzone()); DCHECK(GetSurfaceFactoryOzone());
return GetSurfaceFactoryOzone()->GetAllowedGLImplementations(); return GetSurfaceFactoryOzone()->GetAllowedGLImplementations();
#else
NOTREACHED();
return {};
#endif
} }
bool GetGLWindowSystemBindingInfo(const GLVersionInfo& gl_info, bool GetGLWindowSystemBindingInfo(const GLVersionInfo& gl_info,
GLWindowSystemBindingInfo* info) { GLWindowSystemBindingInfo* info) {
#if defined(USE_X11)
if (!features::IsUsingOzonePlatform())
return gl::init::GetGLWindowSystemBindingInfoX11(gl_info, info);
#endif
#if defined(USE_OZONE)
if (HasGLOzone()) if (HasGLOzone())
return GetGLOzone()->GetGLWindowSystemBindingInfo(gl_info, info); return GetGLOzone()->GetGLWindowSystemBindingInfo(gl_info, info);
#endif
return false; return false;
} }
...@@ -35,6 +60,13 @@ bool GetGLWindowSystemBindingInfo(const GLVersionInfo& gl_info, ...@@ -35,6 +60,13 @@ bool GetGLWindowSystemBindingInfo(const GLVersionInfo& gl_info,
scoped_refptr<GLContext> CreateGLContext(GLShareGroup* share_group, scoped_refptr<GLContext> CreateGLContext(GLShareGroup* share_group,
GLSurface* compatible_surface, GLSurface* compatible_surface,
const GLContextAttribs& attribs) { const GLContextAttribs& attribs) {
#if defined(USE_X11)
if (!features::IsUsingOzonePlatform())
return gl::init::CreateGLContextX11(share_group, compatible_surface,
attribs);
#endif
#if defined(USE_OZONE)
TRACE_EVENT0("gpu", "gl::init::CreateGLContext"); TRACE_EVENT0("gpu", "gl::init::CreateGLContext");
if (HasGLOzone()) { if (HasGLOzone()) {
...@@ -56,10 +88,18 @@ scoped_refptr<GLContext> CreateGLContext(GLShareGroup* share_group, ...@@ -56,10 +88,18 @@ scoped_refptr<GLContext> CreateGLContext(GLShareGroup* share_group,
default: default:
NOTREACHED() << "Expected Mock or Stub, actual:" << GetGLImplementation(); NOTREACHED() << "Expected Mock or Stub, actual:" << GetGLImplementation();
} }
#endif
return nullptr; return nullptr;
} }
scoped_refptr<GLSurface> CreateViewGLSurface(gfx::AcceleratedWidget window) { scoped_refptr<GLSurface> CreateViewGLSurface(gfx::AcceleratedWidget window) {
#if defined(USE_X11)
if (!features::IsUsingOzonePlatform())
return gl::init::CreateViewGLSurfaceX11(window);
#endif
#if defined(USE_OZONE)
TRACE_EVENT0("gpu", "gl::init::CreateViewGLSurface"); TRACE_EVENT0("gpu", "gl::init::CreateViewGLSurface");
if (HasGLOzone()) if (HasGLOzone())
...@@ -72,22 +112,37 @@ scoped_refptr<GLSurface> CreateViewGLSurface(gfx::AcceleratedWidget window) { ...@@ -72,22 +112,37 @@ scoped_refptr<GLSurface> CreateViewGLSurface(gfx::AcceleratedWidget window) {
default: default:
NOTREACHED() << "Expected Mock or Stub, actual:" << GetGLImplementation(); NOTREACHED() << "Expected Mock or Stub, actual:" << GetGLImplementation();
} }
#endif
return nullptr; return nullptr;
} }
scoped_refptr<GLSurface> CreateSurfacelessViewGLSurface( scoped_refptr<GLSurface> CreateSurfacelessViewGLSurface(
gfx::AcceleratedWidget window) { gfx::AcceleratedWidget window) {
#if defined(USE_X11)
if (!features::IsUsingOzonePlatform()) {
return nullptr;
}
#endif
#if defined(USE_OZONE)
TRACE_EVENT0("gpu", "gl::init::CreateSurfacelessViewGLSurface"); TRACE_EVENT0("gpu", "gl::init::CreateSurfacelessViewGLSurface");
if (HasGLOzone()) if (HasGLOzone())
return GetGLOzone()->CreateSurfacelessViewGLSurface(window); return GetGLOzone()->CreateSurfacelessViewGLSurface(window);
#endif
return nullptr; return nullptr;
} }
scoped_refptr<GLSurface> CreateOffscreenGLSurfaceWithFormat( scoped_refptr<GLSurface> CreateOffscreenGLSurfaceWithFormat(
const gfx::Size& size, GLSurfaceFormat format) { const gfx::Size& size, GLSurfaceFormat format) {
#if defined(USE_X11)
if (!features::IsUsingOzonePlatform())
return gl::init::CreateOffscreenGLSurfaceWithFormatX11(size, format);
#endif
#if defined(USE_OZONE)
TRACE_EVENT0("gpu", "gl::init::CreateOffscreenGLSurface"); TRACE_EVENT0("gpu", "gl::init::CreateOffscreenGLSurface");
if (!format.IsCompatible(GLSurfaceFormat())) { if (!format.IsCompatible(GLSurfaceFormat())) {
...@@ -105,11 +160,20 @@ scoped_refptr<GLSurface> CreateOffscreenGLSurfaceWithFormat( ...@@ -105,11 +160,20 @@ scoped_refptr<GLSurface> CreateOffscreenGLSurfaceWithFormat(
default: default:
NOTREACHED() << "Expected Mock or Stub, actual:" << GetGLImplementation(); NOTREACHED() << "Expected Mock or Stub, actual:" << GetGLImplementation();
} }
#endif
return nullptr; return nullptr;
} }
void SetDisabledExtensionsPlatform(const std::string& disabled_extensions) { void SetDisabledExtensionsPlatform(const std::string& disabled_extensions) {
#if defined(USE_X11)
if (!features::IsUsingOzonePlatform()) {
gl::init::SetDisabledExtensionsPlatformX11(disabled_extensions);
return;
}
#endif
#if defined(USE_OZONE)
if (HasGLOzone()) { if (HasGLOzone()) {
GetGLOzone()->SetDisabledExtensionsPlatform(disabled_extensions); GetGLOzone()->SetDisabledExtensionsPlatform(disabled_extensions);
return; return;
...@@ -122,9 +186,16 @@ void SetDisabledExtensionsPlatform(const std::string& disabled_extensions) { ...@@ -122,9 +186,16 @@ void SetDisabledExtensionsPlatform(const std::string& disabled_extensions) {
default: default:
NOTREACHED() << "Expected Mock or Stub, actual:" << GetGLImplementation(); NOTREACHED() << "Expected Mock or Stub, actual:" << GetGLImplementation();
} }
#endif
} }
bool InitializeExtensionSettingsOneOffPlatform() { bool InitializeExtensionSettingsOneOffPlatform() {
#if defined(USE_X11)
if (!features::IsUsingOzonePlatform())
return gl::init::InitializeExtensionSettingsOneOffPlatformX11();
#endif
#if defined(USE_OZONE)
if (HasGLOzone()) if (HasGLOzone())
return GetGLOzone()->InitializeExtensionSettingsOneOffPlatform(); return GetGLOzone()->InitializeExtensionSettingsOneOffPlatform();
...@@ -136,6 +207,8 @@ bool InitializeExtensionSettingsOneOffPlatform() { ...@@ -136,6 +207,8 @@ bool InitializeExtensionSettingsOneOffPlatform() {
NOTREACHED() << "Expected Mock or Stub, actual:" << GetGLImplementation(); NOTREACHED() << "Expected Mock or Stub, actual:" << GetGLImplementation();
return false; return false;
} }
#endif
return false;
} }
} // namespace init } // namespace init
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ui/gl/init/gl_initializer.h" #include "ui/gl/init/gl_initializer_linux_x11.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/logging.h" #include "base/logging.h"
...@@ -45,7 +45,7 @@ const char kEGLSwiftShaderLibraryName[] = "libEGL.so"; ...@@ -45,7 +45,7 @@ const char kEGLSwiftShaderLibraryName[] = "libEGL.so";
#endif #endif
bool InitializeStaticGLXInternal() { bool InitializeStaticGLXInternal() {
base::NativeLibrary library = NULL; base::NativeLibrary library = nullptr;
const base::CommandLine* command_line = const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess(); base::CommandLine::ForCurrentProcess();
...@@ -142,7 +142,7 @@ bool InitializeStaticEGLInternal(GLImplementation implementation) { ...@@ -142,7 +142,7 @@ bool InitializeStaticEGLInternal(GLImplementation implementation) {
} // namespace } // namespace
bool InitializeGLOneOffPlatform() { bool InitializeGLOneOffPlatformX11() {
switch (GetGLImplementation()) { switch (GetGLImplementation()) {
case kGLImplementationDesktopGL: case kGLImplementationDesktopGL:
if (!GLSurfaceGLX::InitializeOneOff()) { if (!GLSurfaceGLX::InitializeOneOff()) {
...@@ -155,8 +155,8 @@ bool InitializeGLOneOffPlatform() { ...@@ -155,8 +155,8 @@ bool InitializeGLOneOffPlatform() {
case kGLImplementationEGLANGLE: case kGLImplementationEGLANGLE:
// Set utility class that helps to initialize egl platform. // Set utility class that helps to initialize egl platform.
gl::GLDisplayEglUtil::SetInstance(gl::GLDisplayEglUtilX11::GetInstance()); gl::GLDisplayEglUtil::SetInstance(gl::GLDisplayEglUtilX11::GetInstance());
if (!GLSurfaceEGL::InitializeOneOff( if (!GLSurfaceEGL::InitializeOneOff(EGLDisplayPlatform(
EGLDisplayPlatform(gfx::GetXDisplay()))) { reinterpret_cast<EGLNativeDisplayType>(gfx::GetXDisplay())))) {
LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed."; LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed.";
return false; return false;
} }
...@@ -166,7 +166,7 @@ bool InitializeGLOneOffPlatform() { ...@@ -166,7 +166,7 @@ bool InitializeGLOneOffPlatform() {
} }
} }
bool InitializeStaticGLBindings(GLImplementation implementation) { bool InitializeStaticGLBindingsX11(GLImplementation implementation) {
// Prevent reinitialization with a different implementation. Once the gpu // Prevent reinitialization with a different implementation. Once the gpu
// unit tests have initialized with kGLImplementationMock, we don't want to // unit tests have initialized with kGLImplementationMock, we don't want to
// later switch to another GL implementation. // later switch to another GL implementation.
...@@ -197,7 +197,7 @@ bool InitializeStaticGLBindings(GLImplementation implementation) { ...@@ -197,7 +197,7 @@ bool InitializeStaticGLBindings(GLImplementation implementation) {
return false; return false;
} }
void ShutdownGLPlatform() { void ShutdownGLPlatformX11() {
GLSurfaceEGL::ShutdownOneOff(); GLSurfaceEGL::ShutdownOneOff();
GLSurfaceGLX::ShutdownOneOff(); GLSurfaceGLX::ShutdownOneOff();
ClearBindingsEGL(); ClearBindingsEGL();
......
// Copyright 2020 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_INIT_GL_INITIALIZER_LINUX_X11_H_
#define UI_GL_INIT_GL_INITIALIZER_LINUX_X11_H_
#include "ui/gl/gl_implementation.h"
namespace gl {
// Note that this is a temporary gl implementation for Linux/X11 GL. It is
// called through GLFactoryOzone, and will be removed as soon as Linux/Ozone is
// default.
//
// TODO(msisov): remove this once Ozone is default on Linux.
namespace init {
// Performs platform dependent one-off GL initialization, calling into the
// appropriate GLSurface code to initialize it. To perform one-off GL
// initialization you should use InitializeGLOneOff() or
// InitializeStaticGLBindingsOneOff() +
// InitializeGLNoExtensionsOneOff(). For tests possibly
// InitializeStaticGLBindingsImplementation() +
// InitializeGLOneOffPlatformImplementation() instead.
bool InitializeGLOneOffPlatformX11();
// Initializes a particular GL implementation.
bool InitializeStaticGLBindingsX11(GLImplementation implementation);
// Clears GL bindings for all implementations supported by platform.
void ShutdownGLPlatformX11();
} // namespace init
} // namespace gl
#endif // UI_GL_INIT_GL_INITIALIZER_LINUX_X11_H_
...@@ -9,14 +9,28 @@ ...@@ -9,14 +9,28 @@
#include "ui/gl/gl_bindings.h" #include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_gl_api_implementation.h" #include "ui/gl/gl_gl_api_implementation.h"
#include "ui/gl/gl_surface.h" #include "ui/gl/gl_surface.h"
#if defined(USE_OZONE)
#include "ui/gl/init/gl_display_egl_util_ozone.h" #include "ui/gl/init/gl_display_egl_util_ozone.h"
#include "ui/gl/init/ozone_util.h" #include "ui/gl/init/ozone_util.h"
#include "ui/ozone/public/ozone_platform.h" #include "ui/ozone/public/ozone_platform.h"
#endif
#if defined(USE_X11)
#include "ui/base/ui_base_features.h"
#include "ui/gl/init/gl_initializer_linux_x11.h"
#endif
namespace gl { namespace gl {
namespace init { namespace init {
bool InitializeGLOneOffPlatform() { bool InitializeGLOneOffPlatform() {
#if defined(USE_X11)
if (!features::IsUsingOzonePlatform())
return gl::init::InitializeGLOneOffPlatformX11();
#endif
#if defined(USE_OZONE)
if (HasGLOzone()) { if (HasGLOzone()) {
gl::GLDisplayEglUtil::SetInstance(gl::GLDisplayEglUtilOzone::GetInstance()); gl::GLDisplayEglUtil::SetInstance(gl::GLDisplayEglUtilOzone::GetInstance());
return GetGLOzone()->InitializeGLOneOffPlatform(); return GetGLOzone()->InitializeGLOneOffPlatform();
...@@ -29,10 +43,17 @@ bool InitializeGLOneOffPlatform() { ...@@ -29,10 +43,17 @@ bool InitializeGLOneOffPlatform() {
default: default:
NOTREACHED(); NOTREACHED();
} }
#endif
return false; return false;
} }
bool InitializeStaticGLBindings(GLImplementation implementation) { bool InitializeStaticGLBindings(GLImplementation implementation) {
#if defined(USE_X11)
if (!features::IsUsingOzonePlatform())
return gl::init::InitializeStaticGLBindingsX11(implementation);
#endif
#if defined(USE_OZONE)
// Prevent reinitialization with a different implementation. Once the gpu // Prevent reinitialization with a different implementation. Once the gpu
// unit tests have initialized with kGLImplementationMock, we don't want to // unit tests have initialized with kGLImplementationMock, we don't want to
// later switch to another GL implementation. // later switch to another GL implementation.
...@@ -52,17 +73,25 @@ bool InitializeStaticGLBindings(GLImplementation implementation) { ...@@ -52,17 +73,25 @@ bool InitializeStaticGLBindings(GLImplementation implementation) {
default: default:
NOTREACHED(); NOTREACHED();
} }
#endif
return false; return false;
} }
void ShutdownGLPlatform() { void ShutdownGLPlatform() {
#if defined(USE_X11)
if (!features::IsUsingOzonePlatform())
return gl::init::ShutdownGLPlatformX11();
#endif
#if defined(USE_OZONE)
if (HasGLOzone()) { if (HasGLOzone()) {
GetGLOzone()->ShutdownGL(); GetGLOzone()->ShutdownGL();
return; return;
} }
ClearBindingsGL(); ClearBindingsGL();
#endif
} }
} // namespace init } // namespace init
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment