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

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: Move refactor to new CL. Created 4 years, 8 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 85c4a1bb5e7098877e925ee83e25cf655ebec93c..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.
rjkroege 2016/04/27 19:08:12 See my previous mutter. I don't really like this.
+ 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;
@@ -99,12 +156,18 @@ 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();
@@ -112,6 +175,10 @@ void ClearGLBindings() {
bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) {
switch (GetGLImplementation()) {
+#if defined(USE_GLX)
+ case kGLImplementationDesktopGL:
+ return GetGLWindowSystemBindingInfoGLX(info);
+#endif
case kGLImplementationEGLGLES2:
return GetGLWindowSystemBindingInfoEGL(info);
default:

Powered by Google App Engine
This is Rietveld 408576698