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

Unified Diff: ui/gl/gl_implementation_ozone.cc

Issue 1723303002: Implement GLX for Ozone X11. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase/refactor. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/gl/gl_implementation_ozone.cc
diff --git a/ui/gl/gl_implementation_ozone.cc b/ui/gl/gl_implementation_ozone.cc
index 715084f50dbf552aea987354bb6b63e3aadc018d..61c52f400ec4c74a4d54191b825f05eec965813b 100644
--- a/ui/gl/gl_implementation_ozone.cc
+++ b/ui/gl/gl_implementation_ozone.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/bind.h"
+#include "base/command_line.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context_stub_with_extensions.h"
#include "ui/gl/gl_egl_api_implementation.h"
@@ -13,6 +14,10 @@
#include "ui/ozone/public/ozone_platform.h"
#include "ui/ozone/public/surface_factory_ozone.h"
+#if defined(USE_GLX)
+#include "ui/gl/gl_glx_api_implementation.h"
+#endif
+
namespace gfx {
namespace {
@@ -26,9 +31,25 @@ void GL_BINDING_CALL MarshalDepthRangeToDepthRangef(GLclampd z_near,
glDepthRangef(static_cast<GLclampf>(z_near), static_cast<GLclampf>(z_far));
}
+#if defined(USE_GLX)
+#if defined(OS_OPENBSD)
+const char kGLLibraryName[] = "libGL.so";
+#else
+const char kGLLibraryName[] = "libGL.so.1";
+#endif
+#endif
+
} // namespace
void GetAllowedGLImplementations(std::vector<GLImplementation>* impls) {
+#if defined(USE_GLX)
+ // TODO: Discuss/change this before submitting CL.
kylechar 2016/03/23 15:40:09 This isn't great. GetAllowedGLImplementations is c
+ ui::OzonePlatform::InitializeForGPU();
+ // DesktopGL implies GLX on Linux. We only support GLX running the Ozone X11
+ // platform, which requires a runtime check.
+ if (ui::OzonePlatform::GetInstance()->GetSurfaceFactoryOzone()->SupportsGLX())
+ impls->push_back(kGLImplementationDesktopGL);
+#endif
impls->push_back(kGLImplementationEGLGLES2);
impls->push_back(kGLImplementationOSMesaGL);
}
@@ -43,6 +64,41 @@ bool InitializeStaticGLBindings(GLImplementation implementation) {
switch (implementation) {
case kGLImplementationOSMesaGL:
return InitializeStaticGLBindingsOSMesaGL();
+#if defined(USE_GLX)
+ case kGLImplementationDesktopGL: {
+ const base::CommandLine* command_line =
+ base::CommandLine::ForCurrentProcess();
+
+ base::NativeLibrary library = nullptr;
+ if (command_line->HasSwitch(switches::kTestGLLib)) {
+ library = LoadLibraryAndPrintError(
+ command_line->GetSwitchValueASCII(switches::kTestGLLib).c_str());
+ } else {
+ library = LoadLibraryAndPrintError(kGLLibraryName);
+ }
+
+ if (!library)
+ return false;
+
+ GLGetProcAddressProc get_proc_address =
+ reinterpret_cast<GLGetProcAddressProc>(
+ base::GetFunctionPointerFromNativeLibrary(library,
+ "glXGetProcAddress"));
+ if (!get_proc_address) {
+ LOG(ERROR) << "glxGetProcAddress not found.";
+ base::UnloadNativeLibrary(library);
+ return false;
+ }
+
+ SetGLGetProcAddressProc(get_proc_address);
+ AddGLNativeLibrary(library);
+ SetGLImplementation(kGLImplementationDesktopGL);
+
+ InitializeStaticGLBindingsGL();
+ InitializeStaticGLBindingsGLX();
+ break;
+ }
+#endif
case kGLImplementationEGLGLES2:
if (!ui::OzonePlatform::GetInstance()
->GetSurfaceFactoryOzone()
@@ -76,6 +132,7 @@ bool InitializeDynamicGLBindings(GLImplementation implementation,
GLContext* context) {
switch (implementation) {
case kGLImplementationOSMesaGL:
+ case kGLImplementationDesktopGL:
case kGLImplementationEGLGLES2:
InitializeDynamicGLBindingsGL(context);
break;
@@ -85,8 +142,9 @@ bool InitializeDynamicGLBindings(GLImplementation implementation,
new GLContextStubWithExtensions());
mock_context->SetGLVersionString("3.0");
InitializeDynamicGLBindingsGL(mock_context.get());
- } else
+ } else {
InitializeDynamicGLBindingsGL(context);
+ }
break;
default:
return false;
@@ -96,17 +154,31 @@ bool InitializeDynamicGLBindings(GLImplementation implementation,
}
void InitializeDebugGLBindings() {
+ InitializeDebugGLBindingsEGL();
+ InitializeDebugGLBindingsGL();
+#if defined(USE_GLX)
+ InitializeDebugGLBindingsGLX();
+#endif
+ InitializeDebugGLBindingsOSMESA();
}
void ClearGLBindings() {
ClearGLBindingsEGL();
ClearGLBindingsGL();
+#if defined(USE_GLX)
+ ClearGLBindingsGLX();
+#endif
+ ClearGLBindingsOSMESA();
SetGLImplementation(kGLImplementationNone);
UnloadGLNativeLibraries();
}
bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) {
switch (GetGLImplementation()) {
+#if defined(USE_GLX)
+ case kGLImplementationDesktopGL:
+ return GetGLWindowSystemBindingInfoGLX(info);
+#endif
case kGLImplementationEGLGLES2:
return GetGLWindowSystemBindingInfoEGL(info);
default:
« no previous file with comments | « ui/gl/gl_implementation.cc ('k') | ui/gl/gl_surface_glx.h » ('j') | ui/gl/gl_surface_x11.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698