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 CreateContextFlags flags
, const SurfaceCaps
& caps
, bool isOffscreen
,
24 Display
* display
, GLXDrawable drawable
, GLXFBConfig cfg
,
25 bool deleteDrawable
, 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 ~GLContextGLX() override
;
38 virtual GLContextType
GetContextType() const override
{
39 return GLContextType::GLX
;
42 static GLContextGLX
* Cast(GLContext
* gl
) {
43 MOZ_ASSERT(gl
->GetContextType() == GLContextType::GLX
);
44 return static_cast<GLContextGLX
*>(gl
);
49 virtual bool MakeCurrentImpl() const override
;
51 virtual bool IsCurrentImpl() const override
;
53 Maybe
<SymbolLoader
> GetSymbolLoader() const override
;
55 virtual bool IsDoubleBuffered() const override
;
57 virtual bool SwapBuffers() override
;
59 virtual 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(CreateContextFlags flags
, const SurfaceCaps
& caps
,
72 bool isOffscreen
, Display
* aDisplay
, GLXDrawable aDrawable
,
73 GLXContext aContext
, bool aDeleteDrawable
, bool aDoubleBuffered
,
74 gfxXlibSurface
* aPixmap
);
78 GLXDrawable mDrawable
;
84 RefPtr
<gfxXlibSurface
> mPixmap
;
85 bool mOwnsContext
= true;
89 } // namespace mozilla
91 #endif // GLCONTEXTGLX_H_