2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2018-11-30 18:39:55 +03:00
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2014-01-08 00:02:18 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef GLCONTEXTGLX_H_
|
|
|
|
#define GLCONTEXTGLX_H_
|
|
|
|
|
|
|
|
#include "GLContext.h"
|
|
|
|
#include "GLXLibrary.h"
|
2016-03-03 08:10:55 +03:00
|
|
|
#include "mozilla/X11Util.h"
|
2014-01-08 00:02:18 +04:00
|
|
|
|
2018-03-13 19:06:56 +03:00
|
|
|
class gfxXlibSurface;
|
|
|
|
|
2014-01-08 00:02:18 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace gl {
|
|
|
|
|
|
|
|
class GLContextGLX : public GLContext {
|
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GLContextGLX, override)
|
2014-01-08 00:02:18 +04:00
|
|
|
static already_AddRefed<GLContextGLX> CreateGLContext(
|
2020-06-15 21:25:55 +03:00
|
|
|
const GLContextDesc&, Display* display, GLXDrawable drawable,
|
|
|
|
GLXFBConfig cfg, bool deleteDrawable, gfxXlibSurface* pixmap);
|
2014-01-08 00:02:18 +04:00
|
|
|
|
2018-03-14 19:24:43 +03:00
|
|
|
static bool FindVisual(Display* display, int screen, bool useWebRender,
|
|
|
|
bool useAlpha, int* const out_visualId);
|
|
|
|
|
2016-03-03 08:10:55 +03:00
|
|
|
// Finds a GLXFBConfig compatible with the provided window.
|
|
|
|
static bool FindFBConfigForWindow(
|
|
|
|
Display* display, int screen, Window window,
|
|
|
|
ScopedXFree<GLXFBConfig>* const out_scopedConfigArr,
|
2017-01-13 23:16:52 +03:00
|
|
|
GLXFBConfig* const out_config, int* const out_visid, bool aWebRender);
|
2016-03-03 08:10:55 +03:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
virtual ~GLContextGLX();
|
2014-01-08 00:02:18 +04:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
GLContextType GetContextType() const override { return GLContextType::GLX; }
|
2014-01-08 00:02:18 +04:00
|
|
|
|
|
|
|
static GLContextGLX* Cast(GLContext* gl) {
|
2014-01-10 22:55:24 +04:00
|
|
|
MOZ_ASSERT(gl->GetContextType() == GLContextType::GLX);
|
2014-01-08 00:02:18 +04:00
|
|
|
return static_cast<GLContextGLX*>(gl);
|
|
|
|
}
|
2014-01-08 00:02:18 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
bool Init() override;
|
2020-07-29 05:33:54 +03:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
bool MakeCurrentImpl() const override;
|
2014-01-08 00:02:18 +04:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
bool IsCurrentImpl() const override;
|
2014-01-08 00:02:18 +04:00
|
|
|
|
2019-02-23 00:17:28 +03:00
|
|
|
Maybe<SymbolLoader> GetSymbolLoader() const override;
|
2014-01-08 00:02:18 +04:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
bool IsDoubleBuffered() const override;
|
2014-01-08 00:02:18 +04:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
bool SwapBuffers() override;
|
2014-01-08 00:02:18 +04:00
|
|
|
|
2020-11-13 21:41:41 +03:00
|
|
|
GLint GetBufferAge() const override;
|
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
void GetWSIInfo(nsCString* const out) const override;
|
2017-01-31 05:58:52 +03:00
|
|
|
|
2015-07-30 19:40:56 +03:00
|
|
|
// Overrides the current GLXDrawable backing the context and makes the
|
|
|
|
// context current.
|
|
|
|
bool OverrideDrawable(GLXDrawable drawable);
|
|
|
|
|
|
|
|
// Undoes the effect of a drawable override.
|
|
|
|
bool RestoreDrawable();
|
|
|
|
|
2014-01-08 00:02:18 +04:00
|
|
|
private:
|
|
|
|
friend class GLContextProviderGLX;
|
|
|
|
|
2020-06-15 21:25:55 +03:00
|
|
|
GLContextGLX(const GLContextDesc&, Display* aDisplay, GLXDrawable aDrawable,
|
2014-01-08 00:02:18 +04:00
|
|
|
GLXContext aContext, bool aDeleteDrawable, bool aDoubleBuffered,
|
2017-03-15 23:14:03 +03:00
|
|
|
gfxXlibSurface* aPixmap);
|
2014-01-08 00:02:18 +04:00
|
|
|
|
|
|
|
GLXContext mContext;
|
2016-06-11 04:37:07 +03:00
|
|
|
Display* mDisplay;
|
2014-01-08 00:02:18 +04:00
|
|
|
GLXDrawable mDrawable;
|
|
|
|
bool mDeleteDrawable;
|
|
|
|
bool mDoubleBuffered;
|
|
|
|
|
|
|
|
GLXLibrary* mGLX;
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<gfxXlibSurface> mPixmap;
|
2018-08-18 01:21:26 +03:00
|
|
|
bool mOwnsContext = true;
|
2014-01-08 00:02:18 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace gl
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // GLCONTEXTGLX_H_
|