• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2015 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 
7 // FunctionsGLX.h: Defines the FunctionsGLX class to load functions and data from GLX
8 
9 #ifndef LIBANGLE_RENDERER_GL_GLX_FUNCTIONSGLX_H_
10 #define LIBANGLE_RENDERER_GL_GLX_FUNCTIONSGLX_H_
11 
12 #include <string>
13 #include <vector>
14 
15 #include "libANGLE/renderer/gl/glx/platform_glx.h"
16 
17 namespace rx
18 {
19 
20 class FunctionsGLX
21 {
22   public:
23     FunctionsGLX();
24     ~FunctionsGLX();
25 
26     // Load data from GLX, can be called multiple times
27     bool initialize(Display *xDisplay, int screen, std::string *errorString);
28     void terminate();
29 
30     bool hasExtension(const char *extension) const;
31     int majorVersion;
32     int minorVersion;
33 
34     Display *getDisplay() const;
35     int getScreen() const;
36 
37     PFNGETPROCPROC getProc;
38 
39     // GLX 1.0
40     glx::Context createContext(XVisualInfo *visual, glx::Context share, bool direct) const;
41     void destroyContext(glx::Context context) const;
42     Bool makeCurrent(glx::Drawable drawable, glx::Context context) const;
43     void swapBuffers(glx::Drawable drawable) const;
44     Bool queryExtension(int *errorBase, int *event) const;
45     Bool queryVersion(int *major, int *minor) const;
46     glx::Context getCurrentContext() const;
47     glx::Drawable getCurrentDrawable() const;
48     void waitX() const;
49     void waitGL() const;
50 
51     // GLX 1.1
52     const char *getClientString(int name) const;
53     const char *queryExtensionsString() const;
54 
55     // GLX 1.3
56     glx::FBConfig *getFBConfigs(int *nElements) const;
57     glx::FBConfig *chooseFBConfig(const int *attribList, int *nElements) const;
58     int getFBConfigAttrib(glx::FBConfig config, int attribute, int *value) const;
59     XVisualInfo *getVisualFromFBConfig(glx::FBConfig config) const;
60     glx::Window createWindow(glx::FBConfig config, Window window, const int *attribList) const;
61     void destroyWindow(glx::Window window) const;
62     glx::Pbuffer createPbuffer(glx::FBConfig config, const int *attribList) const;
63     void destroyPbuffer(glx::Pbuffer pbuffer) const;
64     void queryDrawable(glx::Drawable drawable, int attribute, unsigned int *value) const;
65 
66     // GLX_ARB_create_context
67     glx::Context createContextAttribsARB(glx::FBConfig config,
68                                          glx::Context shareContext,
69                                          Bool direct,
70                                          const int *attribList) const;
71 
72     // GLX_EXT_swap_control
73     void swapIntervalEXT(glx::Drawable drawable, int interval) const;
74 
75     // GLX_MESA_swap_control
76     int swapIntervalMESA(int interval) const;
77 
78     // GLX_SGI_swap_control
79     int swapIntervalSGI(int interval) const;
80 
81     // GLX_OML_sync_control
82     bool getSyncValuesOML(glx::Drawable drawable, int64_t *ust, int64_t *msc, int64_t *sbc) const;
83     bool getMscRateOML(glx::Drawable drawable, int32_t *numerator, int32_t *denominator) const;
84 
85   private:
86     // So as to isolate GLX from angle we do not include angleutils.h and cannot
87     // use angle::NonCopyable so we replicated it here instead.
88     FunctionsGLX(const FunctionsGLX &) = delete;
89     void operator=(const FunctionsGLX &) = delete;
90 
91     struct GLXFunctionTable;
92 
93     static void *sLibHandle;
94     Display *mXDisplay;
95     int mXScreen;
96 
97     GLXFunctionTable *mFnPtrs;
98     std::vector<std::string> mExtensions;
99 };
100 
101 }  // namespace rx
102 
103 #endif  // LIBANGLE_RENDERER_GL_GLX_FUNCTIONSGLX_H_
104