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
|
|
|
|
|
2010-06-15 10:55:08 +04:00
|
|
|
#include "GLContext.h"
|
|
|
|
typedef realGLboolean GLboolean;
|
|
|
|
#include <GL/glx.h>
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gl {
|
|
|
|
|
|
|
|
class GLXLibrary
|
|
|
|
{
|
|
|
|
public:
|
2011-10-17 18:59:28 +04:00
|
|
|
GLXLibrary() : mInitialized(false), mTriedInitializing(false),
|
2012-04-18 18:27:32 +04:00
|
|
|
mUseTextureFromPixmap(false), mDebug(false),
|
2012-09-07 04:16:30 +04:00
|
|
|
mHasRobustness(false), mIsATI(false),
|
|
|
|
mClientIsMesa(false), mGLXMajorVersion(0),
|
|
|
|
mGLXMinorVersion(0), mLibType(OPENGL_LIB),
|
|
|
|
mOGLLibrary(nullptr) {}
|
2011-08-24 05:55:43 +04:00
|
|
|
|
|
|
|
void xDestroyContext(Display* display, GLXContext context);
|
|
|
|
Bool xMakeCurrent(Display* display,
|
|
|
|
GLXDrawable drawable,
|
|
|
|
GLXContext context);
|
2012-09-07 04:16:30 +04:00
|
|
|
|
|
|
|
enum LibraryType
|
|
|
|
{
|
|
|
|
OPENGL_LIB = 0,
|
|
|
|
MESA_LLVMPIPE_LIB = 1,
|
|
|
|
LIBS_MAX
|
|
|
|
};
|
|
|
|
|
2011-08-24 05:55:43 +04:00
|
|
|
GLXContext xGetCurrentContext();
|
|
|
|
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,
|
|
|
|
Bool direct);
|
|
|
|
int xGetFBConfigAttrib(Display *display,
|
|
|
|
GLXFBConfig config,
|
|
|
|
int attribute,
|
|
|
|
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,
|
|
|
|
GLXFBConfig config,
|
|
|
|
Pixmap pixmap,
|
|
|
|
const int *attrib_list);
|
|
|
|
GLXPixmap xCreateGLXPixmapWithConfig(Display *display,
|
|
|
|
GLXFBConfig config,
|
|
|
|
Pixmap pixmap);
|
|
|
|
void xDestroyPixmap(Display *display, GLXPixmap pixmap);
|
|
|
|
Bool xQueryVersion(Display *display,
|
|
|
|
int *major,
|
|
|
|
int *minor);
|
|
|
|
void xBindTexImage(Display *display,
|
|
|
|
GLXDrawable drawable,
|
|
|
|
int buffer,
|
|
|
|
const int *attrib_list);
|
|
|
|
void xReleaseTexImage(Display *display,
|
|
|
|
GLXDrawable drawable,
|
|
|
|
int buffer);
|
|
|
|
void xWaitGL();
|
2011-08-24 05:56:30 +04:00
|
|
|
void xWaitX();
|
2010-06-15 10:55:08 +04:00
|
|
|
|
2011-10-27 00:00:44 +04:00
|
|
|
GLXContext xCreateContextAttribs(Display* display,
|
|
|
|
GLXFBConfig config,
|
|
|
|
GLXContext share_list,
|
|
|
|
Bool direct,
|
|
|
|
const int* attrib_list);
|
|
|
|
|
2012-09-07 04:16:30 +04:00
|
|
|
bool EnsureInitialized(bool aUseMesaLLVMPipe);
|
2011-08-24 05:55:43 +04:00
|
|
|
|
|
|
|
GLXPixmap CreatePixmap(gfxASurface* aSurface);
|
|
|
|
void DestroyPixmap(GLXPixmap aPixmap);
|
|
|
|
void BindTexImage(GLXPixmap aPixmap);
|
|
|
|
void ReleaseTexImage(GLXPixmap aPixmap);
|
|
|
|
|
2012-04-18 18:27:32 +04:00
|
|
|
bool UseTextureFromPixmap() { return mUseTextureFromPixmap; }
|
2011-10-27 00:00:44 +04:00
|
|
|
bool HasRobustness() { return mHasRobustness; }
|
2011-09-29 10:19:26 +04:00
|
|
|
bool SupportsTextureFromPixmap(gfxASurface* aSurface);
|
2012-09-07 04:16:30 +04:00
|
|
|
bool IsATI() { return mIsATI; }
|
|
|
|
bool GLXVersionCheck(int aMajor, int aMinor);
|
|
|
|
static LibraryType SelectLibrary(const GLContext::ContextFlags& aFlags);
|
2011-08-24 05:55:43 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
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;
|
2010-06-15 10:55:08 +04:00
|
|
|
typedef void* (GLAPIENTRY * PFNGLXGETPROCADDRESSPROC) (const char *);
|
2011-08-24 05:55:43 +04:00
|
|
|
PFNGLXGETPROCADDRESSPROC xGetProcAddressInternal;
|
2010-06-15 10:55:08 +04:00
|
|
|
typedef GLXFBConfig* (GLAPIENTRY * PFNGLXCHOOSEFBCONFIG) (Display *,
|
|
|
|
int,
|
|
|
|
const int *,
|
|
|
|
int *);
|
2011-08-24 05:55:43 +04:00
|
|
|
PFNGLXCHOOSEFBCONFIG xChooseFBConfigInternal;
|
2010-06-19 03:17:00 +04:00
|
|
|
typedef GLXFBConfig* (GLAPIENTRY * PFNGLXGETFBCONFIGS) (Display *,
|
|
|
|
int,
|
|
|
|
int *);
|
2011-08-24 05:55:43 +04:00
|
|
|
PFNGLXGETFBCONFIGS xGetFBConfigsInternal;
|
2010-06-15 10:55:08 +04:00
|
|
|
typedef GLXContext (GLAPIENTRY * PFNGLXCREATENEWCONTEXT) (Display *,
|
|
|
|
GLXFBConfig,
|
|
|
|
int,
|
|
|
|
GLXContext,
|
|
|
|
Bool);
|
2011-08-24 05:55:43 +04:00
|
|
|
PFNGLXCREATENEWCONTEXT xCreateNewContextInternal;
|
2010-06-19 03:17:00 +04:00
|
|
|
typedef int (GLAPIENTRY * PFNGLXGETFBCONFIGATTRIB) (Display *,
|
|
|
|
GLXFBConfig,
|
|
|
|
int,
|
|
|
|
int *);
|
2011-08-24 05:55:43 +04:00
|
|
|
PFNGLXGETFBCONFIGATTRIB xGetFBConfigAttribInternal;
|
2010-06-19 03:17:00 +04:00
|
|
|
|
|
|
|
typedef void (GLAPIENTRY * PFNGLXSWAPBUFFERS) (Display *,
|
|
|
|
GLXDrawable);
|
2011-08-24 05:55:43 +04:00
|
|
|
PFNGLXSWAPBUFFERS xSwapBuffersInternal;
|
2010-11-10 18:49:52 +03:00
|
|
|
typedef const char * (GLAPIENTRY * PFNGLXQUERYEXTENSIONSSTRING) (Display *,
|
|
|
|
int);
|
2011-08-24 05:55:43 +04:00
|
|
|
PFNGLXQUERYEXTENSIONSSTRING xQueryExtensionsStringInternal;
|
2011-03-25 06:38:59 +03:00
|
|
|
typedef const char * (GLAPIENTRY * PFNGLXGETCLIENTSTRING) (Display *,
|
|
|
|
int);
|
2011-08-24 05:55:43 +04:00
|
|
|
PFNGLXGETCLIENTSTRING xGetClientStringInternal;
|
2010-06-19 03:17:00 +04: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
|
|
|
|
2010-07-19 09:01:14 +04:00
|
|
|
typedef GLXPixmap (GLAPIENTRY * PFNGLXCREATEPIXMAP) (Display *,
|
|
|
|
GLXFBConfig,
|
|
|
|
Pixmap,
|
|
|
|
const int *);
|
2011-08-24 05:55:43 +04:00
|
|
|
PFNGLXCREATEPIXMAP xCreatePixmapInternal;
|
2010-11-10 18:49:52 +03:00
|
|
|
typedef GLXPixmap (GLAPIENTRY * PFNGLXCREATEGLXPIXMAPWITHCONFIG)
|
|
|
|
(Display *,
|
|
|
|
GLXFBConfig,
|
|
|
|
Pixmap);
|
2011-08-24 05:55:43 +04:00
|
|
|
PFNGLXCREATEGLXPIXMAPWITHCONFIG xCreateGLXPixmapWithConfigInternal;
|
2010-07-19 09:01:14 +04:00
|
|
|
typedef void (GLAPIENTRY * PFNGLXDESTROYPIXMAP) (Display *,
|
|
|
|
GLXPixmap);
|
2011-08-24 05:55:43 +04:00
|
|
|
PFNGLXDESTROYPIXMAP xDestroyPixmapInternal;
|
2010-11-10 18:49:52 +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
|
|
|
|
2011-04-08 03:58:07 +04:00
|
|
|
typedef void (GLAPIENTRY * PFNGLXBINDTEXIMAGE) (Display *,
|
|
|
|
GLXDrawable,
|
|
|
|
int,
|
|
|
|
const int *);
|
2011-08-24 05:55:43 +04:00
|
|
|
PFNGLXBINDTEXIMAGE xBindTexImageInternal;
|
2011-04-08 03:58:07 +04:00
|
|
|
|
|
|
|
typedef void (GLAPIENTRY * PFNGLXRELEASETEXIMAGE) (Display *,
|
|
|
|
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;
|
2011-08-24 05:56:30 +04:00
|
|
|
|
|
|
|
typedef void (GLAPIENTRY * PFNGLXWAITX) ();
|
|
|
|
PFNGLXWAITGL xWaitXInternal;
|
2011-04-08 03:58:07 +04:00
|
|
|
|
2011-10-27 00:00:44 +04:00
|
|
|
typedef GLXContext (GLAPIENTRY * PFNGLXCREATECONTEXTATTRIBS) (Display *,
|
|
|
|
GLXFBConfig,
|
|
|
|
GLXContext,
|
|
|
|
Bool,
|
|
|
|
const int *);
|
|
|
|
PFNGLXCREATECONTEXTATTRIBS xCreateContextAttribsInternal;
|
|
|
|
|
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;
|
2012-09-07 04:16:30 +04:00
|
|
|
bool mIsATI;
|
|
|
|
bool mClientIsMesa;
|
|
|
|
int mGLXMajorVersion;
|
|
|
|
int mGLXMinorVersion;
|
|
|
|
LibraryType mLibType;
|
2010-06-15 10:55:08 +04:00
|
|
|
PRLibrary *mOGLLibrary;
|
|
|
|
};
|
|
|
|
|
|
|
|
// a global GLXLibrary instance
|
2012-09-07 04:16:30 +04:00
|
|
|
extern GLXLibrary sGLXLibrary[GLXLibrary::LIBS_MAX];
|
|
|
|
extern GLXLibrary& sDefGLXLib;
|
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
|
|
|
|