1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 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/. */
7 #ifndef GLCONTEXTGLX_H_
8 #define GLCONTEXTGLX_H_
10 #include "GLContext.h"
11 #include "GLXLibrary.h"
12 #include "mozilla/X11Util.h"
19 class GLContextGLX
: public GLContext
{
21 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GLContextGLX
, override
)
22 static already_AddRefed
<GLContextGLX
> CreateGLContext(
23 const GLContextDesc
&, std::shared_ptr
<gfx::XlibDisplay
> display
,
24 GLXDrawable drawable
, GLXFBConfig cfg
, bool deleteDrawable
,
25 gfxXlibSurface
* pixmap
);
27 static bool FindVisual(Display
* display
, int screen
, bool useWebRender
,
28 bool useAlpha
, int* const out_visualId
);
30 // Finds a GLXFBConfig compatible with the provided window.
31 static bool FindFBConfigForWindow(
32 Display
* display
, int screen
, Window window
,
33 ScopedXFree
<GLXFBConfig
>* const out_scopedConfigArr
,
34 GLXFBConfig
* const out_config
, int* const out_visid
, bool aWebRender
);
36 virtual ~GLContextGLX();
38 GLContextType
GetContextType() const override
{ return GLContextType::GLX
; }
40 static GLContextGLX
* Cast(GLContext
* gl
) {
41 MOZ_ASSERT(gl
->GetContextType() == GLContextType::GLX
);
42 return static_cast<GLContextGLX
*>(gl
);
47 bool MakeCurrentImpl() const override
;
49 bool IsCurrentImpl() const override
;
51 Maybe
<SymbolLoader
> GetSymbolLoader() const override
;
53 bool IsDoubleBuffered() const override
;
55 bool SwapBuffers() override
;
57 GLint
GetBufferAge() const override
;
59 void GetWSIInfo(nsCString
* const out
) const override
;
61 // Overrides the current GLXDrawable backing the context and makes the
63 bool OverrideDrawable(GLXDrawable drawable
);
65 // Undoes the effect of a drawable override.
66 bool RestoreDrawable();
69 friend class GLContextProviderGLX
;
71 GLContextGLX(const GLContextDesc
&, std::shared_ptr
<gfx::XlibDisplay
> aDisplay
,
72 GLXDrawable aDrawable
, GLXContext aContext
, bool aDeleteDrawable
,
73 bool aDoubleBuffered
, gfxXlibSurface
* aPixmap
);
75 const GLXContext mContext
;
76 const std::shared_ptr
<gfx::XlibDisplay
> mDisplay
;
77 const GLXDrawable mDrawable
;
78 const bool mDeleteDrawable
;
79 const bool mDoubleBuffered
;
81 GLXLibrary
* const mGLX
;
83 const RefPtr
<gfxXlibSurface
> mPixmap
;
84 const bool mOwnsContext
= true;
88 } // namespace mozilla
90 #endif // GLCONTEXTGLX_H_