2010-06-15 10:55:08 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2012-05-21 15:12:37 +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/. */
|
2010-06-15 10:55:08 +04:00
|
|
|
|
2011-04-08 03:58:07 +04:00
|
|
|
#ifndef GFX_GLXLIBRARY_H
|
|
|
|
#define GFX_GLXLIBRARY_H
|
|
|
|
|
2013-09-04 16:14:52 +04:00
|
|
|
#include "GLContextTypes.h"
|
2010-06-15 10:55:08 +04:00
|
|
|
typedef realGLboolean GLboolean;
|
2013-11-18 17:08:24 +04:00
|
|
|
|
|
|
|
// stuff from glx.h
|
|
|
|
#include "X11/Xlib.h"
|
2016-06-11 04:37:07 +03:00
|
|
|
typedef struct __GLXcontextRec* GLXContext;
|
2013-11-18 17:08:24 +04:00
|
|
|
typedef XID GLXPixmap;
|
|
|
|
typedef XID GLXDrawable;
|
|
|
|
/* GLX 1.3 and later */
|
2016-06-11 04:37:07 +03:00
|
|
|
typedef struct __GLXFBConfigRec* GLXFBConfig;
|
2013-11-18 17:08:24 +04:00
|
|
|
typedef XID GLXFBConfigID;
|
|
|
|
typedef XID GLXContextID;
|
|
|
|
typedef XID GLXWindow;
|
|
|
|
typedef XID GLXPbuffer;
|
|
|
|
// end of stuff from glx.h
|
2015-09-24 23:05:45 +03:00
|
|
|
#include "prenv.h"
|
2010-06-15 10:55:08 +04:00
|
|
|
|
2013-09-04 16:14:52 +04:00
|
|
|
struct PRLibrary;
|
2013-12-03 22:44:38 +04:00
|
|
|
class gfxASurface;
|
2013-09-04 16:14:52 +04:00
|
|
|
|
2010-06-15 10:55:08 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace gl {
|
|
|
|
|
|
|
|
class GLXLibrary
|
|
|
|
{
|
|
|
|
public:
|
2016-02-22 21:54:24 +03:00
|
|
|
MOZ_CONSTEXPR GLXLibrary()
|
2016-01-20 16:46:25 +03:00
|
|
|
: xDestroyContextInternal(nullptr)
|
|
|
|
, xMakeCurrentInternal(nullptr)
|
|
|
|
, xGetCurrentContextInternal(nullptr)
|
|
|
|
, xGetProcAddressInternal(nullptr)
|
|
|
|
, xChooseFBConfigInternal(nullptr)
|
|
|
|
, xGetFBConfigsInternal(nullptr)
|
|
|
|
, xCreateNewContextInternal(nullptr)
|
|
|
|
, xGetFBConfigAttribInternal(nullptr)
|
|
|
|
, xSwapBuffersInternal(nullptr)
|
|
|
|
, xQueryExtensionsStringInternal(nullptr)
|
|
|
|
, xGetClientStringInternal(nullptr)
|
|
|
|
, xQueryServerStringInternal(nullptr)
|
|
|
|
, xCreatePixmapInternal(nullptr)
|
|
|
|
, xCreateGLXPixmapWithConfigInternal(nullptr)
|
|
|
|
, xDestroyPixmapInternal(nullptr)
|
|
|
|
, xQueryVersionInternal(nullptr)
|
|
|
|
, xBindTexImageInternal(nullptr)
|
|
|
|
, xReleaseTexImageInternal(nullptr)
|
|
|
|
, xWaitGLInternal(nullptr)
|
|
|
|
, xWaitXInternal(nullptr)
|
|
|
|
, xCreateContextAttribsInternal(nullptr)
|
2016-05-09 18:35:36 +03:00
|
|
|
, xGetVideoSyncInternal(nullptr)
|
|
|
|
, xWaitVideoSyncInternal(nullptr)
|
2016-01-20 16:46:25 +03:00
|
|
|
, mInitialized(false), mTriedInitializing(false)
|
|
|
|
, mUseTextureFromPixmap(false), mDebug(false)
|
|
|
|
, mHasRobustness(false), mHasCreateContextAttribs(false)
|
2016-05-09 18:35:36 +03:00
|
|
|
, mHasVideoSync(false)
|
2016-01-20 16:46:25 +03:00
|
|
|
, mIsATI(false), mIsNVIDIA(false)
|
|
|
|
, mClientIsMesa(false), mGLXMajorVersion(0)
|
|
|
|
, mGLXMinorVersion(0)
|
|
|
|
, mOGLLibrary(nullptr)
|
|
|
|
{}
|
2011-08-24 05:55:43 +04:00
|
|
|
|
|
|
|
void xDestroyContext(Display* display, GLXContext context);
|
2016-06-11 04:37:07 +03:00
|
|
|
Bool xMakeCurrent(Display* display,
|
|
|
|
GLXDrawable drawable,
|
2011-08-24 05:55:43 +04:00
|
|
|
GLXContext context);
|
2012-09-07 04:16:30 +04:00
|
|
|
|
2011-08-24 05:55:43 +04:00
|
|
|
GLXContext xGetCurrentContext();
|
2016-06-11 04:37:07 +03:00
|
|
|
static void* xGetProcAddress(const char* procName);
|
|
|
|
GLXFBConfig* xChooseFBConfig(Display* display,
|
|
|
|
int screen,
|
|
|
|
const int* attrib_list,
|
|
|
|
int* nelements);
|
|
|
|
GLXFBConfig* xGetFBConfigs(Display* display,
|
|
|
|
int screen,
|
|
|
|
int* nelements);
|
|
|
|
GLXContext xCreateNewContext(Display* display,
|
|
|
|
GLXFBConfig config,
|
|
|
|
int render_type,
|
|
|
|
GLXContext share_list,
|
2011-08-24 05:55:43 +04:00
|
|
|
Bool direct);
|
2016-06-11 04:37:07 +03:00
|
|
|
int xGetFBConfigAttrib(Display* display,
|
2011-08-24 05:55:43 +04:00
|
|
|
GLXFBConfig config,
|
|
|
|
int attribute,
|
2016-06-11 04:37:07 +03:00
|
|
|
int* value);
|
|
|
|
void xSwapBuffers(Display* display, GLXDrawable drawable);
|
|
|
|
const char* xQueryExtensionsString(Display* display,
|
|
|
|
int screen);
|
|
|
|
const char* xGetClientString(Display* display,
|
|
|
|
int screen);
|
|
|
|
const char* xQueryServerString(Display* display,
|
|
|
|
int screen, int name);
|
|
|
|
GLXPixmap xCreatePixmap(Display* display,
|
2011-08-24 05:55:43 +04:00
|
|
|
GLXFBConfig config,
|
|
|
|
Pixmap pixmap,
|
2016-06-11 04:37:07 +03:00
|
|
|
const int* attrib_list);
|
|
|
|
GLXPixmap xCreateGLXPixmapWithConfig(Display* display,
|
2011-08-24 05:55:43 +04:00
|
|
|
GLXFBConfig config,
|
|
|
|
Pixmap pixmap);
|
2016-06-11 04:37:07 +03:00
|
|
|
void xDestroyPixmap(Display* display, GLXPixmap pixmap);
|
|
|
|
Bool xQueryVersion(Display* display,
|
|
|
|
int* major,
|
|
|
|
int* minor);
|
|
|
|
void xBindTexImage(Display* display,
|
2011-08-24 05:55:43 +04:00
|
|
|
GLXDrawable drawable,
|
|
|
|
int buffer,
|
2016-06-11 04:37:07 +03:00
|
|
|
const int* attrib_list);
|
|
|
|
void xReleaseTexImage(Display* display,
|
2011-08-24 05:55:43 +04:00
|
|
|
GLXDrawable drawable,
|
|
|
|
int buffer);
|
|
|
|
void xWaitGL();
|
2011-08-24 05:56:30 +04:00
|
|
|
void xWaitX();
|
2010-06-15 10:55:08 +04:00
|
|
|
|
2016-06-11 04:37:07 +03:00
|
|
|
GLXContext xCreateContextAttribs(Display* display,
|
|
|
|
GLXFBConfig config,
|
|
|
|
GLXContext share_list,
|
2011-10-27 00:00:44 +04:00
|
|
|
Bool direct,
|
|
|
|
const int* attrib_list);
|
|
|
|
|
2016-05-09 18:35:36 +03:00
|
|
|
int xGetVideoSync(unsigned int* count);
|
|
|
|
int xWaitVideoSync(int divisor, int remainder, unsigned int* count);
|
|
|
|
|
2014-01-10 22:55:23 +04:00
|
|
|
bool EnsureInitialized();
|
2011-08-24 05:55:43 +04:00
|
|
|
|
|
|
|
GLXPixmap CreatePixmap(gfxASurface* aSurface);
|
2014-02-25 03:56:51 +04:00
|
|
|
void DestroyPixmap(Display* aDisplay, GLXPixmap aPixmap);
|
|
|
|
void BindTexImage(Display* aDisplay, GLXPixmap aPixmap);
|
|
|
|
void ReleaseTexImage(Display* aDisplay, GLXPixmap aPixmap);
|
|
|
|
void UpdateTexImage(Display* aDisplay, GLXPixmap aPixmap);
|
2011-08-24 05:55:43 +04:00
|
|
|
|
2012-04-18 18:27:32 +04:00
|
|
|
bool UseTextureFromPixmap() { return mUseTextureFromPixmap; }
|
2011-10-27 00:00:44 +04:00
|
|
|
bool HasRobustness() { return mHasRobustness; }
|
2015-10-22 17:49:06 +03:00
|
|
|
bool HasCreateContextAttribs() { return mHasCreateContextAttribs; }
|
2011-09-29 10:19:26 +04:00
|
|
|
bool SupportsTextureFromPixmap(gfxASurface* aSurface);
|
2016-05-09 18:35:36 +03:00
|
|
|
bool SupportsVideoSync();
|
2012-09-07 04:16:30 +04:00
|
|
|
bool IsATI() { return mIsATI; }
|
|
|
|
bool GLXVersionCheck(int aMajor, int aMinor);
|
2011-08-24 05:55:43 +04:00
|
|
|
|
|
|
|
private:
|
2016-06-11 04:37:07 +03:00
|
|
|
|
2010-11-10 18:49:52 +03:00
|
|
|
typedef void (GLAPIENTRY * PFNGLXDESTROYCONTEXTPROC) (Display*,
|
|
|
|
GLXContext);
|
2011-08-24 05:55:43 +04:00
|
|
|
PFNGLXDESTROYCONTEXTPROC xDestroyContextInternal;
|
2010-06-15 10:55:08 +04:00
|
|
|
typedef Bool (GLAPIENTRY * PFNGLXMAKECURRENTPROC) (Display*,
|
|
|
|
GLXDrawable,
|
|
|
|
GLXContext);
|
2011-08-24 05:55:43 +04:00
|
|
|
PFNGLXMAKECURRENTPROC xMakeCurrentInternal;
|
2010-09-20 21:19:30 +04:00
|
|
|
typedef GLXContext (GLAPIENTRY * PFNGLXGETCURRENTCONTEXT) ();
|
2011-08-24 05:55:43 +04:00
|
|
|
PFNGLXGETCURRENTCONTEXT xGetCurrentContextInternal;
|
2016-06-11 04:37:07 +03:00
|
|
|
typedef void* (GLAPIENTRY * PFNGLXGETPROCADDRESSPROC) (const char*);
|
2011-08-24 05:55:43 +04:00
|
|
|
PFNGLXGETPROCADDRESSPROC xGetProcAddressInternal;
|
2016-06-11 04:37:07 +03:00
|
|
|
typedef GLXFBConfig* (GLAPIENTRY * PFNGLXCHOOSEFBCONFIG) (Display*,
|
2010-06-15 10:55:08 +04:00
|
|
|
int,
|
2016-06-11 04:37:07 +03:00
|
|
|
const int*,
|
|
|
|
int*);
|
2011-08-24 05:55:43 +04:00
|
|
|
PFNGLXCHOOSEFBCONFIG xChooseFBConfigInternal;
|
2016-06-11 04:37:07 +03:00
|
|
|
typedef GLXFBConfig* (GLAPIENTRY * PFNGLXGETFBCONFIGS) (Display*,
|
2010-06-19 03:17:00 +04:00
|
|
|
int,
|
2016-06-11 04:37:07 +03:00
|
|
|
int*);
|
2011-08-24 05:55:43 +04:00
|
|
|
PFNGLXGETFBCONFIGS xGetFBConfigsInternal;
|
2016-06-11 04:37:07 +03:00
|
|
|
typedef GLXContext (GLAPIENTRY * PFNGLXCREATENEWCONTEXT) (Display*,
|
2010-06-15 10:55:08 +04:00
|
|
|
GLXFBConfig,
|
|
|
|
int,
|
|
|
|
GLXContext,
|
|
|
|
Bool);
|
2011-08-24 05:55:43 +04:00
|
|
|
PFNGLXCREATENEWCONTEXT xCreateNewContextInternal;
|
2016-06-11 04:37:07 +03:00
|
|
|
typedef int (GLAPIENTRY * PFNGLXGETFBCONFIGATTRIB) (Display*,
|
2010-06-19 03:17:00 +04:00
|
|
|
GLXFBConfig,
|
|
|
|
int,
|
2016-06-11 04:37:07 +03:00
|
|
|
int*);
|
2011-08-24 05:55:43 +04:00
|
|
|
PFNGLXGETFBCONFIGATTRIB xGetFBConfigAttribInternal;
|
2010-06-19 03:17:00 +04:00
|
|
|
|
2016-06-11 04:37:07 +03:00
|
|
|
typedef void (GLAPIENTRY * PFNGLXSWAPBUFFERS) (Display*,
|
2010-06-19 03:17:00 +04:00
|
|
|
GLXDrawable);
|
2011-08-24 05:55:43 +04:00
|
|
|
PFNGLXSWAPBUFFERS xSwapBuffersInternal;
|
2016-06-11 04:37:07 +03:00
|
|
|
typedef const char* (GLAPIENTRY * PFNGLXQUERYEXTENSIONSSTRING) (Display*,
|
|
|
|
int);
|
2011-08-24 05:55:43 +04:00
|
|
|
PFNGLXQUERYEXTENSIONSSTRING xQueryExtensionsStringInternal;
|
2016-06-11 04:37:07 +03:00
|
|
|
typedef const char* (GLAPIENTRY * PFNGLXGETCLIENTSTRING) (Display*,
|
|
|
|
int);
|
2011-08-24 05:55:43 +04:00
|
|
|
PFNGLXGETCLIENTSTRING xGetClientStringInternal;
|
2016-06-11 04:37:07 +03:00
|
|
|
typedef const char* (GLAPIENTRY * PFNGLXQUERYSERVERSTRING) (Display*,
|
|
|
|
int,
|
|
|
|
int);
|
2011-08-24 05:55:43 +04:00
|
|
|
PFNGLXQUERYSERVERSTRING xQueryServerStringInternal;
|
2010-06-19 03:17:00 +04:00
|
|
|
|
2016-06-11 04:37:07 +03:00
|
|
|
typedef GLXPixmap (GLAPIENTRY * PFNGLXCREATEPIXMAP) (Display*,
|
2010-07-19 09:01:14 +04:00
|
|
|
GLXFBConfig,
|
|
|
|
Pixmap,
|
2016-06-11 04:37:07 +03:00
|
|
|
const int*);
|
2011-08-24 05:55:43 +04:00
|
|
|
PFNGLXCREATEPIXMAP xCreatePixmapInternal;
|
2010-11-10 18:49:52 +03:00
|
|
|
typedef GLXPixmap (GLAPIENTRY * PFNGLXCREATEGLXPIXMAPWITHCONFIG)
|
2016-06-11 04:37:07 +03:00
|
|
|
(Display*,
|
2010-11-10 18:49:52 +03:00
|
|
|
GLXFBConfig,
|
|
|
|
Pixmap);
|
2011-08-24 05:55:43 +04:00
|
|
|
PFNGLXCREATEGLXPIXMAPWITHCONFIG xCreateGLXPixmapWithConfigInternal;
|
2016-06-11 04:37:07 +03:00
|
|
|
typedef void (GLAPIENTRY * PFNGLXDESTROYPIXMAP) (Display*,
|
2010-07-19 09:01:14 +04:00
|
|
|
GLXPixmap);
|
2011-08-24 05:55:43 +04:00
|
|
|
PFNGLXDESTROYPIXMAP xDestroyPixmapInternal;
|
2016-06-11 04:37:07 +03:00
|
|
|
typedef Bool (GLAPIENTRY * PFNGLXQUERYVERSION) (Display*,
|
|
|
|
int*,
|
|
|
|
int*);
|
2011-08-24 05:55:43 +04:00
|
|
|
PFNGLXQUERYVERSION xQueryVersionInternal;
|
2010-07-19 09:01:14 +04:00
|
|
|
|
2016-06-11 04:37:07 +03:00
|
|
|
typedef void (GLAPIENTRY * PFNGLXBINDTEXIMAGE) (Display*,
|
2011-04-08 03:58:07 +04:00
|
|
|
GLXDrawable,
|
|
|
|
int,
|
2016-06-11 04:37:07 +03:00
|
|
|
const int*);
|
2011-08-24 05:55:43 +04:00
|
|
|
PFNGLXBINDTEXIMAGE xBindTexImageInternal;
|
2011-04-08 03:58:07 +04:00
|
|
|
|
2016-06-11 04:37:07 +03:00
|
|
|
typedef void (GLAPIENTRY * PFNGLXRELEASETEXIMAGE) (Display*,
|
2011-04-08 03:58:07 +04:00
|
|
|
GLXDrawable,
|
|
|
|
int);
|
2011-08-24 05:55:43 +04:00
|
|
|
PFNGLXRELEASETEXIMAGE xReleaseTexImageInternal;
|
2011-04-08 03:58:07 +04:00
|
|
|
|
|
|
|
typedef void (GLAPIENTRY * PFNGLXWAITGL) ();
|
2011-08-24 05:55:43 +04:00
|
|
|
PFNGLXWAITGL xWaitGLInternal;
|
2016-06-11 04:37:07 +03:00
|
|
|
|
2011-08-24 05:56:30 +04:00
|
|
|
typedef void (GLAPIENTRY * PFNGLXWAITX) ();
|
|
|
|
PFNGLXWAITGL xWaitXInternal;
|
2011-04-08 03:58:07 +04:00
|
|
|
|
2016-06-11 04:37:07 +03:00
|
|
|
typedef GLXContext (GLAPIENTRY * PFNGLXCREATECONTEXTATTRIBS) (Display*,
|
2011-10-27 00:00:44 +04:00
|
|
|
GLXFBConfig,
|
|
|
|
GLXContext,
|
|
|
|
Bool,
|
2016-06-11 04:37:07 +03:00
|
|
|
const int*);
|
2011-10-27 00:00:44 +04:00
|
|
|
PFNGLXCREATECONTEXTATTRIBS xCreateContextAttribsInternal;
|
|
|
|
|
2016-06-11 04:37:07 +03:00
|
|
|
typedef int (GLAPIENTRY * PFNGLXGETVIDEOSYNCSGI) (unsigned int* count);
|
2016-05-09 18:35:36 +03:00
|
|
|
PFNGLXGETVIDEOSYNCSGI xGetVideoSyncInternal;
|
|
|
|
|
2016-06-11 04:37:07 +03:00
|
|
|
typedef int (GLAPIENTRY * PFNGLXWAITVIDEOSYNCSGI) (int divisor, int remainder, unsigned int* count);
|
2016-05-09 18:35:36 +03:00
|
|
|
PFNGLXWAITVIDEOSYNCSGI xWaitVideoSyncInternal;
|
|
|
|
|
2011-08-24 05:55:43 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
void BeforeGLXCall();
|
|
|
|
void AfterGLXCall();
|
|
|
|
#endif
|
2011-04-08 03:58:07 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mInitialized;
|
|
|
|
bool mTriedInitializing;
|
2012-04-18 18:27:32 +04:00
|
|
|
bool mUseTextureFromPixmap;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mDebug;
|
2011-10-27 00:00:44 +04:00
|
|
|
bool mHasRobustness;
|
2015-10-22 17:49:06 +03:00
|
|
|
bool mHasCreateContextAttribs;
|
2016-05-09 18:35:36 +03:00
|
|
|
bool mHasVideoSync;
|
2012-09-07 04:16:30 +04:00
|
|
|
bool mIsATI;
|
2013-08-20 16:30:26 +04:00
|
|
|
bool mIsNVIDIA;
|
2012-09-07 04:16:30 +04:00
|
|
|
bool mClientIsMesa;
|
|
|
|
int mGLXMajorVersion;
|
|
|
|
int mGLXMinorVersion;
|
2016-06-11 04:37:07 +03:00
|
|
|
PRLibrary* mOGLLibrary;
|
2010-06-15 10:55:08 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
// a global GLXLibrary instance
|
2014-01-10 22:55:23 +04:00
|
|
|
extern GLXLibrary sGLXLibrary;
|
2010-06-15 10:55:08 +04:00
|
|
|
|
|
|
|
} /* namespace gl */
|
|
|
|
} /* namespace mozilla */
|
2011-04-08 03:58:07 +04:00
|
|
|
#endif /* GFX_GLXLIBRARY_H */
|
2010-06-15 10:55:08 +04:00
|
|
|
|