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

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: 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 if (!library)
48 return false;
49
50 gl::GLGetProcAddressProc get_proc_address =
51 reinterpret_cast<gl::GLGetProcAddressProc>(
52 base::GetFunctionPointerFromNativeLibrary(library,
53 "glXGetProcAddress"));
54 if (!get_proc_address) {
55 LOG(ERROR) << "glxGetProcAddress not found.";
56 base::UnloadNativeLibrary(library);
57 return false;
58 }
59
60 gl::SetGLGetProcAddressProc(get_proc_address);
61 gl::AddGLNativeLibrary(library);
62 gl::SetGLImplementation(gl::kGLImplementationDesktopGL);
63
64 gl::InitializeStaticGLBindingsGL();
65 gl::InitializeStaticGLBindingsGLX();
66
67 return true;
68 }
69
70 void GLOzoneGLX::InitializeDebugGLBindings() {
71 gl::InitializeDebugGLBindingsGL();
72 gl::InitializeDebugGLBindingsGLX();
73 }
74
75 void GLOzoneGLX::ClearGLBindings() {
76 gl::ClearGLBindingsGL();
77 gl::ClearGLBindingsGLX();
78 }
79
80 bool GLOzoneGLX::GetGLWindowSystemBindingInfo(
81 gl::GLWindowSystemBindingInfo* info) {
82 return gl::GetGLWindowSystemBindingInfoGLX(info);
83 }
84
85 scoped_refptr<gl::GLContext> GLOzoneGLX::CreateGLContext(
86 gl::GLShareGroup* share_group,
87 gl::GLSurface* compatible_surface,
88 gl::GpuPreference gpu_preference) {
89 return gl::InitializeGLContext(new gl::GLContextGLX(share_group),
90 compatible_surface, gpu_preference);
91 }
92
93 scoped_refptr<gl::GLSurface> GLOzoneGLX::CreateViewGLSurface(
94 gfx::AcceleratedWidget window) {
95 return gl::InitializeGLSurface(new GLSurfaceGLXOzone(window));
96 }
97
98 scoped_refptr<gl::GLSurface> GLOzoneGLX::CreateSurfacelessViewGLSurface(
99 gfx::AcceleratedWidget window) {
100 return nullptr;
101 }
102
103 scoped_refptr<gl::GLSurface> GLOzoneGLX::CreateOffscreenGLSurface(
104 const gfx::Size& size) {
105 return gl::InitializeGLSurface(new gl::UnmappedNativeViewGLSurfaceGLX(size));
106 }
107
108 } // namespace ui
OLDNEW
« 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