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

Side by Side 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: Rebase and cleanup. 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/ozone/platform/x11/gl_ozone_glx.h"
6
7 #include "base/command_line.h"
8 #include "ui/gl/gl_context.h"
9 #include "ui/gl/gl_context_glx.h"
10 #include "ui/gl/gl_gl_api_implementation.h"
11 #include "ui/gl/gl_glx_api_implementation.h"
12 #include "ui/ozone/platform/x11/gl_surface_glx_ozone.h"
13
14 namespace ui {
15
16 namespace {
17
18 #if defined(OS_OPENBSD)
19 const char kGLLibraryName[] = "libGL.so";
20 #else
21 const char kGLLibraryName[] = "libGL.so.1";
22 #endif
23
24 } // namespace
25
26 bool GLOzoneGLX::InitializeGLOneOffPlatform() {
27 if (!gl::GLSurfaceGLX::InitializeOneOff()) {
28 LOG(ERROR) << "GLSurfaceGLX::InitializeOneOff failed.";
29 return false;
30 }
31 return true;
32 }
33
34 bool GLOzoneGLX::InitializeStaticGLBindings(
35 gl::GLImplementation implementation) {
36 base::NativeLibrary library = nullptr;
37 const base::CommandLine* command_line =
38 base::CommandLine::ForCurrentProcess();
39
40 if (command_line->HasSwitch(switches::kTestGLLib))
41 library = gl::LoadLibraryAndPrintError(
42 command_line->GetSwitchValueASCII(switches::kTestGLLib).c_str());
43
44 if (!library) {
45 library = gl::LoadLibraryAndPrintError(kGLLibraryName);
46 }
47
48 if (!library)
49 return false;
50
51 gl::GLGetProcAddressProc get_proc_address =
52 reinterpret_cast<gl::GLGetProcAddressProc>(
53 base::GetFunctionPointerFromNativeLibrary(library,
54 "glXGetProcAddress"));
55 if (!get_proc_address) {
56 LOG(ERROR) << "glxGetProcAddress not found.";
57 base::UnloadNativeLibrary(library);
58 return false;
59 }
60
61 gl::SetGLGetProcAddressProc(get_proc_address);
62 gl::AddGLNativeLibrary(library);
63 gl::SetGLImplementation(gl::kGLImplementationDesktopGL);
64
65 gl::InitializeStaticGLBindingsGL();
66 gl::InitializeStaticGLBindingsGLX();
67
68 return true;
69 }
70
71 void GLOzoneGLX::InitializeDebugGLBindings() {
72 gl::InitializeDebugGLBindingsGL();
73 gl::InitializeDebugGLBindingsGLX();
74 }
75
76 void GLOzoneGLX::ClearGLBindings() {
77 gl::ClearGLBindingsGL();
78 gl::ClearGLBindingsGLX();
79 }
80
81 bool GLOzoneGLX::GetGLWindowSystemBindingInfo(
82 gl::GLWindowSystemBindingInfo* info) {
83 return gl::GetGLWindowSystemBindingInfoGLX(info);
84 }
85
86 scoped_refptr<gl::GLContext> GLOzoneGLX::CreateGLContext(
87 gl::GLShareGroup* share_group,
88 gl::GLSurface* compatible_surface,
89 gl::GpuPreference gpu_preference) {
90 return gl::InitializeGLContext(new gl::GLContextGLX(share_group),
91 compatible_surface, gpu_preference);
92 }
93
94 scoped_refptr<gl::GLSurface> GLOzoneGLX::CreateViewGLSurface(
95 gfx::AcceleratedWidget window) {
96 return gl::InitializeGLSurface(new GLSurfaceGLXOzone(window));
97 }
98
99 scoped_refptr<gl::GLSurface> GLOzoneGLX::CreateSurfacelessViewGLSurface(
100 gfx::AcceleratedWidget window) {
101 return nullptr;
102 }
103
104 scoped_refptr<gl::GLSurface> GLOzoneGLX::CreateOffscreenGLSurface(
105 const gfx::Size& size) {
106 return gl::InitializeGLSurface(new gl::UnmappedNativeViewGLSurfaceGLX(size));
107 }
108
109 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698