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

Unified Diff: ui/ozone/platform/x11/gl_ozone_glx.cc

Issue 1723303002: Implement GLX for Ozone X11. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change to use #define Created 4 years, 3 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
« no previous file with comments | « ui/ozone/platform/x11/gl_ozone_glx.h ('k') | ui/ozone/platform/x11/gl_surface_glx_ozone.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/ozone/platform/x11/gl_ozone_glx.cc
diff --git a/ui/ozone/platform/x11/gl_ozone_glx.cc b/ui/ozone/platform/x11/gl_ozone_glx.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0b08e31e4de2236eda3c30f441e7fef663751a03
--- /dev/null
+++ b/ui/ozone/platform/x11/gl_ozone_glx.cc
@@ -0,0 +1,108 @@
+// Copyright 2016 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/ozone/platform/x11/gl_ozone_glx.h"
+
+#include "base/command_line.h"
+#include "ui/gl/gl_context.h"
+#include "ui/gl/gl_context_glx.h"
+#include "ui/gl/gl_gl_api_implementation.h"
+#include "ui/gl/gl_glx_api_implementation.h"
+#include "ui/ozone/platform/x11/gl_surface_glx_ozone.h"
+
+namespace ui {
+
+namespace {
+
+#if defined(OS_OPENBSD)
+const char kGLLibraryName[] = "libGL.so";
+#else
+const char kGLLibraryName[] = "libGL.so.1";
+#endif
+
+} // namespace
+
+bool GLOzoneGLX::InitializeGLOneOffPlatform() {
+ if (!gl::GLSurfaceGLX::InitializeOneOff()) {
+ LOG(ERROR) << "GLSurfaceGLX::InitializeOneOff failed.";
+ return false;
+ }
+ return true;
+}
+
+bool GLOzoneGLX::InitializeStaticGLBindings(
+ gl::GLImplementation implementation) {
+ base::NativeLibrary library = nullptr;
+ const base::CommandLine* command_line =
+ base::CommandLine::ForCurrentProcess();
+
+ if (command_line->HasSwitch(switches::kTestGLLib))
+ library = gl::LoadLibraryAndPrintError(
+ command_line->GetSwitchValueASCII(switches::kTestGLLib).c_str());
+
+ if (!library)
+ library = gl::LoadLibraryAndPrintError(kGLLibraryName);
+
+ if (!library)
+ return false;
+
+ gl::GLGetProcAddressProc get_proc_address =
+ reinterpret_cast<gl::GLGetProcAddressProc>(
+ base::GetFunctionPointerFromNativeLibrary(library,
+ "glXGetProcAddress"));
+ if (!get_proc_address) {
+ LOG(ERROR) << "glxGetProcAddress not found.";
+ base::UnloadNativeLibrary(library);
+ return false;
+ }
+
+ gl::SetGLGetProcAddressProc(get_proc_address);
+ gl::AddGLNativeLibrary(library);
+ gl::SetGLImplementation(gl::kGLImplementationDesktopGL);
+
+ gl::InitializeStaticGLBindingsGL();
+ gl::InitializeStaticGLBindingsGLX();
+
+ return true;
+}
+
+void GLOzoneGLX::InitializeDebugGLBindings() {
+ gl::InitializeDebugGLBindingsGL();
+ gl::InitializeDebugGLBindingsGLX();
+}
+
+void GLOzoneGLX::ClearGLBindings() {
+ gl::ClearGLBindingsGL();
+ gl::ClearGLBindingsGLX();
+}
+
+bool GLOzoneGLX::GetGLWindowSystemBindingInfo(
+ gl::GLWindowSystemBindingInfo* info) {
+ return gl::GetGLWindowSystemBindingInfoGLX(info);
+}
+
+scoped_refptr<gl::GLContext> GLOzoneGLX::CreateGLContext(
+ gl::GLShareGroup* share_group,
+ gl::GLSurface* compatible_surface,
+ gl::GpuPreference gpu_preference) {
+ return gl::InitializeGLContext(new gl::GLContextGLX(share_group),
+ compatible_surface, gpu_preference);
+}
+
+scoped_refptr<gl::GLSurface> GLOzoneGLX::CreateViewGLSurface(
+ gfx::AcceleratedWidget window) {
+ return gl::InitializeGLSurface(new GLSurfaceGLXOzone(window));
+}
+
+scoped_refptr<gl::GLSurface> GLOzoneGLX::CreateSurfacelessViewGLSurface(
+ gfx::AcceleratedWidget window) {
+ return nullptr;
+}
+
+scoped_refptr<gl::GLSurface> GLOzoneGLX::CreateOffscreenGLSurface(
+ const gfx::Size& size) {
+ return gl::InitializeGLSurface(new gl::UnmappedNativeViewGLSurfaceGLX(size));
+}
+
+} // namespace ui
« no previous file with comments | « ui/ozone/platform/x11/gl_ozone_glx.h ('k') | ui/ozone/platform/x11/gl_surface_glx_ozone.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698