Bug 1779627 - Migrate toolkit/components/mozintl/mozIntl.jsm to esm; r=nordzilla
[gecko.git] / gfx / gl / GLContextGLX.h
blob7e7ff109aca854cedbceda4a275ff651c3605872
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"
14 class gfxXlibSurface;
16 namespace mozilla {
17 namespace gl {
19 class GLContextGLX : public GLContext {
20 public:
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, int* const out_visualId);
29 // Finds a GLXFBConfig compatible with the provided window.
30 static bool FindFBConfigForWindow(
31 Display* display, int screen, Window window,
32 ScopedXFree<GLXFBConfig>* const out_scopedConfigArr,
33 GLXFBConfig* const out_config, int* const out_visid, bool aWebRender);
35 virtual ~GLContextGLX();
37 GLContextType GetContextType() const override { return GLContextType::GLX; }
39 static GLContextGLX* Cast(GLContext* gl) {
40 MOZ_ASSERT(gl->GetContextType() == GLContextType::GLX);
41 return static_cast<GLContextGLX*>(gl);
44 bool Init() override;
46 bool MakeCurrentImpl() const override;
48 bool IsCurrentImpl() const override;
50 Maybe<SymbolLoader> GetSymbolLoader() const override;
52 bool IsDoubleBuffered() const override;
54 bool SwapBuffers() override;
56 GLint GetBufferAge() const override;
58 void GetWSIInfo(nsCString* const out) const override;
60 // Overrides the current GLXDrawable backing the context and makes the
61 // context current.
62 bool OverrideDrawable(GLXDrawable drawable);
64 // Undoes the effect of a drawable override.
65 bool RestoreDrawable();
67 private:
68 friend class GLContextProviderGLX;
70 GLContextGLX(const GLContextDesc&, std::shared_ptr<gfx::XlibDisplay> aDisplay,
71 GLXDrawable aDrawable, GLXContext aContext, bool aDeleteDrawable,
72 bool aDoubleBuffered, gfxXlibSurface* aPixmap);
74 const GLXContext mContext;
75 const std::shared_ptr<gfx::XlibDisplay> mDisplay;
76 const GLXDrawable mDrawable;
77 const bool mDeleteDrawable;
78 const bool mDoubleBuffered;
80 GLXLibrary* const mGLX;
82 const RefPtr<gfxXlibSurface> mPixmap;
83 const bool mOwnsContext = true;
86 } // namespace gl
87 } // namespace mozilla
89 #endif // GLCONTEXTGLX_H_