/src/mozilla-central/gfx/gl/GLContextGLX.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* vim: set ts=8 sts=4 et sw=4 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef GLCONTEXTGLX_H_ |
8 | | #define GLCONTEXTGLX_H_ |
9 | | |
10 | | #include "GLContext.h" |
11 | | #include "GLXLibrary.h" |
12 | | #include "mozilla/X11Util.h" |
13 | | |
14 | | class gfxXlibSurface; |
15 | | |
16 | | namespace mozilla { |
17 | | namespace gl { |
18 | | |
19 | | class GLContextGLX : public GLContext |
20 | | { |
21 | | public: |
22 | | MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GLContextGLX, override) |
23 | | static already_AddRefed<GLContextGLX> |
24 | | CreateGLContext(CreateContextFlags flags, |
25 | | const SurfaceCaps& caps, |
26 | | bool isOffscreen, |
27 | | Display* display, |
28 | | GLXDrawable drawable, |
29 | | GLXFBConfig cfg, |
30 | | bool deleteDrawable, |
31 | | gfxXlibSurface* pixmap); |
32 | | |
33 | | static bool |
34 | | FindVisual(Display* display, int screen, bool useWebRender, |
35 | | bool useAlpha, int* const out_visualId); |
36 | | |
37 | | // Finds a GLXFBConfig compatible with the provided window. |
38 | | static bool |
39 | | FindFBConfigForWindow(Display* display, int screen, Window window, |
40 | | ScopedXFree<GLXFBConfig>* const out_scopedConfigArr, |
41 | | GLXFBConfig* const out_config, int* const out_visid, |
42 | | bool aWebRender); |
43 | | |
44 | | ~GLContextGLX(); |
45 | | |
46 | 0 | virtual GLContextType GetContextType() const override { return GLContextType::GLX; } |
47 | | |
48 | 0 | static GLContextGLX* Cast(GLContext* gl) { |
49 | 0 | MOZ_ASSERT(gl->GetContextType() == GLContextType::GLX); |
50 | 0 | return static_cast<GLContextGLX*>(gl); |
51 | 0 | } |
52 | | |
53 | | bool Init() override; |
54 | | |
55 | | virtual bool MakeCurrentImpl() const override; |
56 | | |
57 | | virtual bool IsCurrentImpl() const override; |
58 | | |
59 | | virtual bool SetupLookupFunction() override; |
60 | | |
61 | | virtual bool IsDoubleBuffered() const override; |
62 | | |
63 | | virtual bool SwapBuffers() override; |
64 | | |
65 | | virtual void GetWSIInfo(nsCString* const out) const override; |
66 | | |
67 | | // Overrides the current GLXDrawable backing the context and makes the |
68 | | // context current. |
69 | | bool OverrideDrawable(GLXDrawable drawable); |
70 | | |
71 | | // Undoes the effect of a drawable override. |
72 | | bool RestoreDrawable(); |
73 | | |
74 | | private: |
75 | | friend class GLContextProviderGLX; |
76 | | |
77 | | GLContextGLX(CreateContextFlags flags, |
78 | | const SurfaceCaps& caps, |
79 | | bool isOffscreen, |
80 | | Display* aDisplay, |
81 | | GLXDrawable aDrawable, |
82 | | GLXContext aContext, |
83 | | bool aDeleteDrawable, |
84 | | bool aDoubleBuffered, |
85 | | gfxXlibSurface* aPixmap); |
86 | | |
87 | | GLXContext mContext; |
88 | | Display* mDisplay; |
89 | | GLXDrawable mDrawable; |
90 | | bool mDeleteDrawable; |
91 | | bool mDoubleBuffered; |
92 | | |
93 | | GLXLibrary* mGLX; |
94 | | |
95 | | RefPtr<gfxXlibSurface> mPixmap; |
96 | | bool mOwnsContext = true; |
97 | | }; |
98 | | |
99 | | } |
100 | | } |
101 | | |
102 | | #endif // GLCONTEXTGLX_H_ |