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