Line data Source code
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 : namespace mozilla {
15 : namespace gl {
16 :
17 : class GLContextGLX : public GLContext
18 : {
19 : public:
20 0 : MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GLContextGLX, override)
21 : static already_AddRefed<GLContextGLX>
22 : CreateGLContext(CreateContextFlags flags,
23 : const SurfaceCaps& caps,
24 : bool isOffscreen,
25 : Display* display,
26 : GLXDrawable drawable,
27 : GLXFBConfig cfg,
28 : bool deleteDrawable,
29 : gfxXlibSurface* pixmap);
30 :
31 : // Finds a GLXFBConfig compatible with the provided window.
32 : static bool
33 : FindFBConfigForWindow(Display* display, int screen, Window window,
34 : ScopedXFree<GLXFBConfig>* const out_scopedConfigArr,
35 : GLXFBConfig* const out_config, int* const out_visid,
36 : bool aWebRender);
37 :
38 : ~GLContextGLX();
39 :
40 0 : virtual GLContextType GetContextType() const override { return GLContextType::GLX; }
41 :
42 0 : static GLContextGLX* Cast(GLContext* gl) {
43 0 : MOZ_ASSERT(gl->GetContextType() == GLContextType::GLX);
44 0 : return static_cast<GLContextGLX*>(gl);
45 : }
46 :
47 : bool Init() override;
48 :
49 : virtual bool MakeCurrentImpl(bool aForce) override;
50 :
51 : virtual bool IsCurrent() override;
52 :
53 : virtual bool SetupLookupFunction() override;
54 :
55 : virtual bool IsDoubleBuffered() const override;
56 :
57 : virtual bool SwapBuffers() override;
58 :
59 : virtual void GetWSIInfo(nsCString* const out) const override;
60 :
61 : // Overrides the current GLXDrawable backing the context and makes the
62 : // context current.
63 : bool OverrideDrawable(GLXDrawable drawable);
64 :
65 : // Undoes the effect of a drawable override.
66 : bool RestoreDrawable();
67 :
68 : private:
69 : friend class GLContextProviderGLX;
70 :
71 : GLContextGLX(CreateContextFlags flags,
72 : const SurfaceCaps& caps,
73 : bool isOffscreen,
74 : Display* aDisplay,
75 : GLXDrawable aDrawable,
76 : GLXContext aContext,
77 : bool aDeleteDrawable,
78 : bool aDoubleBuffered,
79 : gfxXlibSurface* aPixmap);
80 :
81 : GLXContext mContext;
82 : Display* mDisplay;
83 : GLXDrawable mDrawable;
84 : bool mDeleteDrawable;
85 : bool mDoubleBuffered;
86 :
87 : GLXLibrary* mGLX;
88 :
89 : RefPtr<gfxXlibSurface> mPixmap;
90 : bool mOwnsContext;
91 : };
92 :
93 : }
94 : }
95 :
96 : #endif // GLCONTEXTGLX_H_
|