--- a/gfx/gl/GLContextProviderGLX.cpp
+++ b/gfx/gl/GLContextProviderGLX.cpp
@@ -156,17 +156,17 @@ GLXLibrary::EnsureInitialized()
return false;
}
Display* display = DefaultXDisplay();
int screen = DefaultScreen(display);
{
int major, minor;
- if (!xQueryVersion(display, &major, &minor) ||
+ if (!fQueryVersion(display, &major, &minor) ||
major != 1 || minor < 4)
{
NS_ERROR("GLX version older than 1.4. (released in 2005)");
return false;
}
}
const auto lookupFunction =
@@ -175,19 +175,19 @@ GLXLibrary::EnsureInitialized()
const auto fnLoadSymbols = [&](const GLLibraryLoader::SymLoadStruct* symbols) {
if (GLLibraryLoader::LoadSymbols(mOGLLibrary, symbols, lookupFunction))
return true;
GLLibraryLoader::ClearSymbols(symbols);
return false;
};
- const char* clientVendor = xGetClientString(display, LOCAL_GLX_VENDOR);
- const char* serverVendor = xQueryServerString(display, screen, LOCAL_GLX_VENDOR);
- const char* extensionsStr = xQueryExtensionsString(display, screen);
+ const char* clientVendor = fGetClientString(display, LOCAL_GLX_VENDOR);
+ const char* serverVendor = fQueryServerString(display, screen, LOCAL_GLX_VENDOR);
+ const char* extensionsStr = fQueryExtensionsString(display, screen);
if (HasExtension(extensionsStr, "GLX_EXT_texture_from_pixmap") &&
fnLoadSymbols(symbols_texturefrompixmap))
{
mUseTextureFromPixmap = gfxPrefs::UseGLXTextureFromPixmap();
} else {
mUseTextureFromPixmap = false;
NS_WARNING("Texture from pixmap disabled");
@@ -273,17 +273,17 @@ GLXLibrary::CreatePixmap(gfxASurface* aS
: LOCAL_GLX_BIND_TO_TEXTURE_RGB_EXT), True,
LOCAL_GLX_RENDER_TYPE, LOCAL_GLX_RGBA_BIT,
X11None };
int numConfigs = 0;
Display* display = xs->XDisplay();
int xscreen = DefaultScreen(display);
- ScopedXFree<GLXFBConfig> cfgs(xChooseFBConfig(display,
+ ScopedXFree<GLXFBConfig> cfgs(fChooseFBConfig(display,
xscreen,
attribs,
&numConfigs));
// Find an fbconfig that matches the pixel format used on the Pixmap.
int matchIndex = -1;
unsigned long redMask =
static_cast<unsigned long>(direct.redMask) << direct.red;
@@ -292,17 +292,17 @@ GLXLibrary::CreatePixmap(gfxASurface* aS
unsigned long blueMask =
static_cast<unsigned long>(direct.blueMask) << direct.blue;
// This is true if the Pixmap has bits for alpha or unused bits.
bool haveNonColorBits =
~(redMask | greenMask | blueMask) != -1UL << format->depth;
for (int i = 0; i < numConfigs; i++) {
int id = X11None;
- sGLXLibrary.xGetFBConfigAttrib(display, cfgs[i], LOCAL_GLX_VISUAL_ID, &id);
+ sGLXLibrary.fGetFBConfigAttrib(display, cfgs[i], LOCAL_GLX_VISUAL_ID, &id);
Visual* visual;
int depth;
FindVisualAndDepth(display, id, &visual, &depth);
if (!visual ||
visual->c_class != TrueColor ||
visual->red_mask != redMask ||
visual->green_mask != greenMask ||
visual->blue_mask != blueMask ) {
@@ -349,17 +349,17 @@ GLXLibrary::CreatePixmap(gfxASurface* aS
// available, except perhaps with NVIDIA drivers where buffer size is
// not the specified sum of the component sizes.
if (haveNonColorBits) {
// There are bits in the Pixmap format that haven't been matched
// against the fbconfig visual. These bits could either represent
// alpha or be unused, so just check that the number of alpha bits
// matches.
int size = 0;
- sGLXLibrary.xGetFBConfigAttrib(display, cfgs[i],
+ sGLXLibrary.fGetFBConfigAttrib(display, cfgs[i],
LOCAL_GLX_ALPHA_SIZE, &size);
if (size != alphaSize) {
continue;
}
}
matchIndex = i;
break;
@@ -374,99 +374,97 @@ GLXLibrary::CreatePixmap(gfxASurface* aS
}
int pixmapAttribs[] = { LOCAL_GLX_TEXTURE_TARGET_EXT, LOCAL_GLX_TEXTURE_2D_EXT,
LOCAL_GLX_TEXTURE_FORMAT_EXT,
(alphaSize ? LOCAL_GLX_TEXTURE_FORMAT_RGBA_EXT
: LOCAL_GLX_TEXTURE_FORMAT_RGB_EXT),
X11None};
- GLXPixmap glxpixmap = xCreatePixmap(display,
+ GLXPixmap glxpixmap = fCreatePixmap(display,
cfgs[matchIndex],
xs->XDrawable(),
pixmapAttribs);
return glxpixmap;
}
void
GLXLibrary::DestroyPixmap(Display* aDisplay, GLXPixmap aPixmap)
{
if (!mUseTextureFromPixmap) {
return;
}
- xDestroyPixmap(aDisplay, aPixmap);
+ fDestroyPixmap(aDisplay, aPixmap);
}
void
GLXLibrary::BindTexImage(Display* aDisplay, GLXPixmap aPixmap)
{
if (!mUseTextureFromPixmap) {
return;
}
// Make sure all X drawing to the surface has finished before binding to a texture.
if (mClientIsMesa) {
// Using XSync instead of Mesa's glXWaitX, because its glxWaitX is a
// noop when direct rendering unless the current drawable is a
// single-buffer window.
FinishX(aDisplay);
} else {
- xWaitX();
+ fWaitX();
}
- xBindTexImage(aDisplay, aPixmap, LOCAL_GLX_FRONT_LEFT_EXT, nullptr);
+ fBindTexImage(aDisplay, aPixmap, LOCAL_GLX_FRONT_LEFT_EXT, nullptr);
}
void
GLXLibrary::ReleaseTexImage(Display* aDisplay, GLXPixmap aPixmap)
{
if (!mUseTextureFromPixmap) {
return;
}
- xReleaseTexImage(aDisplay, aPixmap, LOCAL_GLX_FRONT_LEFT_EXT);
+ fReleaseTexImage(aDisplay, aPixmap, LOCAL_GLX_FRONT_LEFT_EXT);
}
void
GLXLibrary::UpdateTexImage(Display* aDisplay, GLXPixmap aPixmap)
{
// NVIDIA drivers don't require a rebind of the pixmap in order
// to display an updated image, and it's faster not to do it.
if (mIsNVIDIA) {
- xWaitX();
+ fWaitX();
return;
}
ReleaseTexImage(aDisplay, aPixmap);
BindTexImage(aDisplay, aPixmap);
}
-#ifdef DEBUG
-
static int (*sOldErrorHandler)(Display*, XErrorEvent*);
ScopedXErrorHandler::ErrorEvent sErrorEvent;
static int GLXErrorHandler(Display* display, XErrorEvent* ev)
{
if (!sErrorEvent.mError.error_code) {
sErrorEvent.mError = *ev;
}
return 0;
}
void
-GLXLibrary::BeforeGLXCall()
+GLXLibrary::BeforeGLXCall() const
{
if (mDebug) {
sOldErrorHandler = XSetErrorHandler(GLXErrorHandler);
}
}
void
-GLXLibrary::AfterGLXCall()
+GLXLibrary::AfterGLXCall() const
{
if (mDebug) {
FinishX(DefaultXDisplay());
if (sErrorEvent.mError.error_code) {
char buffer[2048];
XGetErrorText(DefaultXDisplay(), sErrorEvent.mError.error_code, buffer, sizeof(buffer));
printf_stderr("X ERROR: %s (%i) - Request: %i.%i, Serial: %lu",
buffer,
@@ -475,277 +473,27 @@ GLXLibrary::AfterGLXCall()
sErrorEvent.mError.minor_code,
sErrorEvent.mError.serial);
NS_ABORT();
}
XSetErrorHandler(sOldErrorHandler);
}
}
-#define BEFORE_GLX_CALL do { \
- sGLXLibrary.BeforeGLXCall(); \
-} while (0)
-
-#define AFTER_GLX_CALL do { \
- sGLXLibrary.AfterGLXCall(); \
-} while (0)
-
-#else
-
-#define BEFORE_GLX_CALL do { } while(0)
-#define AFTER_GLX_CALL do { } while(0)
-
-#endif
-
-void
-GLXLibrary::xDestroyContext(Display* display, GLXContext context)
-{
- BEFORE_GLX_CALL;
- mSymbols.fDestroyContext(display, context);
- AFTER_GLX_CALL;
-}
-
-Bool
-GLXLibrary::xMakeCurrent(Display* display,
- GLXDrawable drawable,
- GLXContext context)
-{
- BEFORE_GLX_CALL;
- const auto result = mSymbols.fMakeCurrent(display, drawable, context);
- AFTER_GLX_CALL;
- return result;
-}
-
-GLXContext
-GLXLibrary::xGetCurrentContext()
-{
- BEFORE_GLX_CALL;
- const auto result = mSymbols.fGetCurrentContext();
- AFTER_GLX_CALL;
- return result;
-}
-
-GLXFBConfig*
-GLXLibrary::xChooseFBConfig(Display* display,
- int screen,
- const int* attrib_list,
- int* nelements)
-{
- BEFORE_GLX_CALL;
- const auto result = mSymbols.fChooseFBConfig(display, screen, attrib_list, nelements);
- AFTER_GLX_CALL;
- return result;
-}
-
-GLXFBConfig*
-GLXLibrary::xGetFBConfigs(Display* display,
- int screen,
- int* nelements)
-{
- BEFORE_GLX_CALL;
- const auto result = mSymbols.fGetFBConfigs(display, screen, nelements);
- AFTER_GLX_CALL;
- return result;
-}
-
-GLXContext
-GLXLibrary::xCreateNewContext(Display* display,
- GLXFBConfig config,
- int render_type,
- GLXContext share_list,
- Bool direct)
-{
- BEFORE_GLX_CALL;
- const auto result = mSymbols.fCreateNewContext(display, config, render_type,
- share_list, direct);
- AFTER_GLX_CALL;
- return result;
-}
-
-int
-GLXLibrary::xGetFBConfigAttrib(Display* display,
- GLXFBConfig config,
- int attribute,
- int* value)
-{
- BEFORE_GLX_CALL;
- const auto result = mSymbols.fGetFBConfigAttrib(display, config, attribute, value);
- AFTER_GLX_CALL;
- return result;
-}
-
-void
-GLXLibrary::xSwapBuffers(Display* display, GLXDrawable drawable)
-{
- BEFORE_GLX_CALL;
- mSymbols.fSwapBuffers(display, drawable);
- AFTER_GLX_CALL;
-}
-
-const char*
-GLXLibrary::xQueryExtensionsString(Display* display,
- int screen)
-{
- BEFORE_GLX_CALL;
- const auto result = mSymbols.fQueryExtensionsString(display, screen);
- AFTER_GLX_CALL;
- return result;
-}
-
-const char*
-GLXLibrary::xGetClientString(Display* display,
- int screen)
-{
- BEFORE_GLX_CALL;
- const auto result = mSymbols.fGetClientString(display, screen);
- AFTER_GLX_CALL;
- return result;
-}
-
-const char*
-GLXLibrary::xQueryServerString(Display* display,
- int screen, int name)
-{
- BEFORE_GLX_CALL;
- const auto result = mSymbols.fQueryServerString(display, screen, name);
- AFTER_GLX_CALL;
- return result;
-}
-
-GLXPixmap
-GLXLibrary::xCreatePixmap(Display* display,
- GLXFBConfig config,
- Pixmap pixmap,
- const int* attrib_list)
-{
- BEFORE_GLX_CALL;
- const auto result = mSymbols.fCreatePixmap(display, config,
- pixmap, attrib_list);
- AFTER_GLX_CALL;
- return result;
-}
-
-GLXPixmap
-GLXLibrary::xCreateGLXPixmapWithConfig(Display* display,
- GLXFBConfig config,
- Pixmap pixmap)
-{
- BEFORE_GLX_CALL;
- const auto result = mSymbols.fCreateGLXPixmapWithConfig(display, config, pixmap);
- AFTER_GLX_CALL;
- return result;
-}
-
-void
-GLXLibrary::xDestroyPixmap(Display* display, GLXPixmap pixmap)
-{
- BEFORE_GLX_CALL;
- mSymbols.fDestroyPixmap(display, pixmap);
- AFTER_GLX_CALL;
-}
-
-Bool
-GLXLibrary::xQueryVersion(Display* display,
- int* major,
- int* minor)
-{
- BEFORE_GLX_CALL;
- const auto result = mSymbols.fQueryVersion(display, major, minor);
- AFTER_GLX_CALL;
- return result;
-}
-
-void
-GLXLibrary::xBindTexImage(Display* display,
- GLXDrawable drawable,
- int buffer,
- const int* attrib_list)
-{
- BEFORE_GLX_CALL;
- mSymbols.fBindTexImageEXT(display, drawable, buffer, attrib_list);
- AFTER_GLX_CALL;
-}
-
-void
-GLXLibrary::xReleaseTexImage(Display* display,
- GLXDrawable drawable,
- int buffer)
-{
- BEFORE_GLX_CALL;
- mSymbols.fReleaseTexImageEXT(display, drawable, buffer);
- AFTER_GLX_CALL;
-}
-
-void
-GLXLibrary::xWaitGL()
-{
- BEFORE_GLX_CALL;
- mSymbols.fWaitGL();
- AFTER_GLX_CALL;
-}
-
-void
-GLXLibrary::xWaitX()
-{
- BEFORE_GLX_CALL;
- mSymbols.fWaitX();
- AFTER_GLX_CALL;
-}
-
-GLXContext
-GLXLibrary::xCreateContextAttribs(Display* display,
- GLXFBConfig config,
- GLXContext share_list,
- Bool direct,
- const int* attrib_list)
-{
- BEFORE_GLX_CALL;
- const auto result = mSymbols.fCreateContextAttribsARB(display, config, share_list,
- direct, attrib_list);
- AFTER_GLX_CALL;
- return result;
-}
-
-int
-GLXLibrary::xGetVideoSync(unsigned int* count)
-{
- BEFORE_GLX_CALL;
- const auto result = mSymbols.fGetVideoSyncSGI(count);
- AFTER_GLX_CALL;
- return result;
-}
-
-int
-GLXLibrary::xWaitVideoSync(int divisor, int remainder, unsigned int* count)
-{
- BEFORE_GLX_CALL;
- const auto result = mSymbols.fWaitVideoSyncSGI(divisor, remainder, count);
- AFTER_GLX_CALL;
- return result;
-}
-
-void
-GLXLibrary::xSwapInterval(Display* display, GLXDrawable drawable, int interval)
-{
- BEFORE_GLX_CALL;
- mSymbols.fSwapIntervalEXT(display, drawable, interval);
- AFTER_GLX_CALL;
-}
-
already_AddRefed<GLContextGLX>
GLContextGLX::CreateGLContext(CreateContextFlags flags, const SurfaceCaps& caps,
GLContextGLX* shareContext, bool isOffscreen,
Display* display, GLXDrawable drawable, GLXFBConfig cfg,
bool deleteDrawable, gfxXlibSurface* pixmap,
ContextProfile profile)
{
GLXLibrary& glx = sGLXLibrary;
int db = 0;
- int err = glx.xGetFBConfigAttrib(display, cfg,
+ int err = glx.fGetFBConfigAttrib(display, cfg,
LOCAL_GLX_DOUBLEBUFFER, &db);
if (LOCAL_GLX_BAD_ATTRIBUTE != err) {
if (ShouldSpew()) {
printf("[GLX] FBConfig is %sdouble-buffered\n", db ? "" : "not ");
}
}
GLXContext context;
@@ -772,24 +520,24 @@ GLContextGLX::CreateGLContext(CreateCont
LOCAL_GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
LOCAL_GLX_CONTEXT_MINOR_VERSION_ARB, 2,
LOCAL_GLX_CONTEXT_FLAGS_ARB, LOCAL_GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
};
attrib_list.AppendElements(core_attribs, MOZ_ARRAY_LENGTH(core_attribs));
};
attrib_list.AppendElement(0);
- context = glx.xCreateContextAttribs(
+ context = glx.fCreateContextAttribs(
display,
cfg,
glxContext,
True,
attrib_list.Elements());
} else {
- context = glx.xCreateNewContext(
+ context = glx.fCreateNewContext(
display,
cfg,
LOCAL_GLX_RGBA_TYPE,
glxContext,
True);
}
if (context) {
@@ -827,25 +575,25 @@ GLContextGLX::~GLContextGLX()
if (!mOwnsContext) {
return;
}
// see bug 659842 comment 76
#ifdef DEBUG
bool success =
#endif
- mGLX->xMakeCurrent(mDisplay, X11None, nullptr);
+ mGLX->fMakeCurrent(mDisplay, X11None, nullptr);
MOZ_ASSERT(success,
"glXMakeCurrent failed to release GL context before we call "
"glXDestroyContext!");
- mGLX->xDestroyContext(mDisplay, mContext);
+ mGLX->fDestroyContext(mDisplay, mContext);
if (mDeleteDrawable) {
- mGLX->xDestroyPixmap(mDisplay, mDrawable);
+ mGLX->fDestroyPixmap(mDisplay, mDrawable);
}
}
bool
GLContextGLX::Init()
{
SetupLookupFunction();
@@ -867,41 +615,41 @@ GLContextGLX::MakeCurrentImpl(bool aForc
bool succeeded = true;
// With the ATI FGLRX driver, glxMakeCurrent is very slow even when the context doesn't change.
// (This is not the case with other drivers such as NVIDIA).
// So avoid calling it more than necessary. Since GLX documentation says that:
// "glXGetCurrentContext returns client-side information.
// It does not make a round trip to the server."
// I assume that it's not worth using our own TLS slot here.
- if (aForce || mGLX->xGetCurrentContext() != mContext) {
+ if (aForce || mGLX->fGetCurrentContext() != mContext) {
if (mGLX->IsMesa()) {
// Read into the event queue to ensure that Mesa receives a
// DRI2InvalidateBuffers event before drawing. See bug 1280653.
Unused << XPending(mDisplay);
}
- succeeded = mGLX->xMakeCurrent(mDisplay, mDrawable, mContext);
+ succeeded = mGLX->fMakeCurrent(mDisplay, mDrawable, mContext);
NS_ASSERTION(succeeded, "Failed to make GL context current!");
if (!IsOffscreen() && mGLX->SupportsSwapControl()) {
// Many GLX implementations default to blocking until the next
// VBlank when calling glXSwapBuffers. We want to run unthrottled
// in ASAP mode. See bug 1280744.
const bool isASAP = (gfxPrefs::LayoutFrameRate() == 0);
- mGLX->xSwapInterval(mDisplay, mDrawable, isASAP ? 0 : 1);
+ mGLX->fSwapInterval(mDisplay, mDrawable, isASAP ? 0 : 1);
}
}
return succeeded;
}
bool
GLContextGLX::IsCurrent() {
- return mGLX->xGetCurrentContext() == mContext;
+ return mGLX->fGetCurrentContext() == mContext;
}
bool
GLContextGLX::SetupLookupFunction()
{
mLookupFunc = (PlatformLookupFunction)sGLXLibrary.GetGetProcAddress();
return true;
}
@@ -918,54 +666,54 @@ GLContextGLX::SupportsRobustness() const
return mGLX->HasRobustness();
}
bool
GLContextGLX::SwapBuffers()
{
if (!mDoubleBuffered)
return false;
- mGLX->xSwapBuffers(mDisplay, mDrawable);
+ mGLX->fSwapBuffers(mDisplay, mDrawable);
return true;
}
void
GLContextGLX::GetWSIInfo(nsCString* const out) const
{
Display* display = DefaultXDisplay();
int screen = DefaultScreen(display);
int majorVersion, minorVersion;
- sGLXLibrary.xQueryVersion(display, &majorVersion, &minorVersion);
+ sGLXLibrary.fQueryVersion(display, &majorVersion, &minorVersion);
out->Append(nsPrintfCString("GLX %u.%u", majorVersion, minorVersion));
out->AppendLiteral("\nGLX_VENDOR(client): ");
- out->Append(sGLXLibrary.xGetClientString(display, LOCAL_GLX_VENDOR));
+ out->Append(sGLXLibrary.fGetClientString(display, LOCAL_GLX_VENDOR));
out->AppendLiteral("\nGLX_VENDOR(server): ");
- out->Append(sGLXLibrary.xQueryServerString(display, screen, LOCAL_GLX_VENDOR));
+ out->Append(sGLXLibrary.fQueryServerString(display, screen, LOCAL_GLX_VENDOR));
out->AppendLiteral("\nExtensions: ");
- out->Append(sGLXLibrary.xQueryExtensionsString(display, screen));
+ out->Append(sGLXLibrary.fQueryExtensionsString(display, screen));
}
bool
GLContextGLX::OverrideDrawable(GLXDrawable drawable)
{
if (Screen())
Screen()->AssureBlitted();
- Bool result = mGLX->xMakeCurrent(mDisplay, drawable, mContext);
+ Bool result = mGLX->fMakeCurrent(mDisplay, drawable, mContext);
return result;
}
bool
GLContextGLX::RestoreDrawable()
{
- return mGLX->xMakeCurrent(mDisplay, mDrawable, mContext);
+ return mGLX->fMakeCurrent(mDisplay, mDrawable, mContext);
}
GLContextGLX::GLContextGLX(
CreateContextFlags flags,
const SurfaceCaps& caps,
GLContext* shareContext,
bool isOffscreen,
Display* aDisplay,
@@ -1143,34 +891,34 @@ ChooseConfig(GLXLibrary* glx, Display* d
LOCAL_GLX_BLUE_SIZE, 8,
LOCAL_GLX_ALPHA_SIZE, minCaps.alpha ? 8 : 0,
LOCAL_GLX_DEPTH_SIZE, minCaps.depth ? 16 : 0,
LOCAL_GLX_STENCIL_SIZE, minCaps.stencil ? 8 : 0,
0
};
int numConfigs = 0;
- scopedConfigArr = glx->xChooseFBConfig(display, screen, attribs, &numConfigs);
+ scopedConfigArr = glx->fChooseFBConfig(display, screen, attribs, &numConfigs);
if (!scopedConfigArr || !numConfigs)
return false;
// Issues with glxChooseFBConfig selection and sorting:
// * ALPHA_SIZE is sorted as 'largest total RGBA bits first'. If we don't request
// alpha bits, we'll probably get RGBA anyways, since 32 is more than 24.
// * DEPTH_SIZE is sorted largest first, including for `0` inputs.
// * STENCIL_SIZE is smallest first, but it might return `8` even though we ask for
// `0`.
// For now, we don't care about these. We *will* care when we do XPixmap sharing.
for (int i = 0; i < numConfigs; ++i) {
GLXFBConfig curConfig = scopedConfigArr[i];
int visid;
- if (glx->xGetFBConfigAttrib(display, curConfig, LOCAL_GLX_VISUAL_ID, &visid)
+ if (glx->fGetFBConfigAttrib(display, curConfig, LOCAL_GLX_VISUAL_ID, &visid)
!= Success)
{
continue;
}
if (!visid)
continue;
@@ -1192,22 +940,22 @@ GLContextGLX::FindFBConfigForWindow(Disp
int numConfigs;
const int webrenderAttribs[] = {
LOCAL_GLX_DEPTH_SIZE, 24,
LOCAL_GLX_DOUBLEBUFFER, True,
0
};
if (aWebRender) {
- cfgs = sGLXLibrary.xChooseFBConfig(display,
+ cfgs = sGLXLibrary.fChooseFBConfig(display,
screen,
webrenderAttribs,
&numConfigs);
} else {
- cfgs = sGLXLibrary.xGetFBConfigs(display,
+ cfgs = sGLXLibrary.fGetFBConfigs(display,
screen,
&numConfigs);
}
if (!cfgs) {
NS_WARNING("[GLX] glXGetFBConfigs() failed");
return false;
}
@@ -1224,17 +972,17 @@ GLContextGLX::FindFBConfigForWindow(Disp
const VisualID windowVisualID = XVisualIDFromVisual(windowAttrs.visual);
#ifdef DEBUG
printf("[GLX] window %lx has VisualID 0x%lx\n", window, windowVisualID);
#endif
if (aWebRender) {
for (int i = 0; i < numConfigs; i++) {
int visid = X11None;
- sGLXLibrary.xGetFBConfigAttrib(display, cfgs[i], LOCAL_GLX_VISUAL_ID, &visid);
+ sGLXLibrary.fGetFBConfigAttrib(display, cfgs[i], LOCAL_GLX_VISUAL_ID, &visid);
if (!visid) {
continue;
}
int depth;
Visual* visual;
FindVisualAndDepth(display, visid, &visual, &depth);
if (depth == windowAttrs.depth &&
@@ -1242,17 +990,17 @@ GLContextGLX::FindFBConfigForWindow(Disp
*out_config = cfgs[i];
*out_visid = visid;
return true;
}
}
} else {
for (int i = 0; i < numConfigs; i++) {
int visid = X11None;
- sGLXLibrary.xGetFBConfigAttrib(display, cfgs[i], LOCAL_GLX_VISUAL_ID, &visid);
+ sGLXLibrary.fGetFBConfigAttrib(display, cfgs[i], LOCAL_GLX_VISUAL_ID, &visid);
if (!visid) {
continue;
}
if (sGLXLibrary.IsATI()) {
int depth;
Visual* visual;
FindVisualAndDepth(display, visid, &visual, &depth);
if (depth == windowAttrs.depth &&
@@ -1310,17 +1058,17 @@ CreateOffscreenPixmapContext(CreateConte
mozilla::Unused << xErrorHandler.SyncAndGetError(display);
return nullptr;
}
// Handle slightly different signature between glXCreatePixmap and
// its pre-GLX-1.3 extension equivalent (though given the ABI, we
// might not need to).
const auto drawable = surface->XDrawable();
- const auto pixmap = glx->xCreatePixmap(display, config, drawable, nullptr);
+ const auto pixmap = glx->fCreatePixmap(display, config, drawable, nullptr);
if (pixmap == 0) {
error = true;
}
bool serverError = xErrorHandler.SyncAndGetError(display);
if (error || serverError)
return nullptr;
--- a/gfx/gl/GLLibraryEGL.cpp
+++ b/gfx/gl/GLLibraryEGL.cpp
@@ -728,36 +728,34 @@ GLLibraryEGL::DumpEGLConfigs()
for (int i = 0; i < nc; ++i) {
printf_stderr("========= EGL Config %d ========\n", i);
DumpEGLConfig(ec[i]);
}
delete [] ec;
}
-#ifdef DEBUG
static bool
ShouldTrace()
{
static bool ret = gfxEnv::GlDebugVerbose();
return ret;
}
-/*static*/ void
-GLLibraryEGL::BeforeGLCall(const char* glFunction)
+void
+BeforeEGLCall(const char* glFunction)
{
if (ShouldTrace()) {
printf_stderr("[egl] > %s\n", glFunction);
}
}
-/*static*/ void
-GLLibraryEGL::AfterGLCall(const char* glFunction)
+void
+AfterEGLCall(const char* glFunction)
{
if (ShouldTrace()) {
printf_stderr("[egl] < %s\n", glFunction);
}
}
-#endif
} /* namespace gl */
} /* namespace mozilla */
--- a/gfx/gl/GLLibraryEGL.h
+++ b/gfx/gl/GLLibraryEGL.h
@@ -59,57 +59,20 @@ class Platform;
namespace mozilla {
namespace gfx {
class DataSourceSurface;
}
namespace gl {
-#undef BEFORE_GL_CALL
-#undef AFTER_GL_CALL
-
-#ifdef DEBUG
-
-#ifndef MOZ_FUNCTION_NAME
-# ifdef __GNUC__
-# define MOZ_FUNCTION_NAME __PRETTY_FUNCTION__
-# elif defined(_MSC_VER)
-# define MOZ_FUNCTION_NAME __FUNCTION__
-# else
-# define MOZ_FUNCTION_NAME __func__ // defined in C99, supported in various C++ compilers. Just raw function name.
-# endif
-#endif
+class GLContext;
-#ifdef MOZ_WIDGET_ANDROID
-// Record the name of the GL call for better hang stacks on Android.
-#define BEFORE_GL_CALL \
- PROFILER_LABEL_FUNC( \
- js::ProfileEntry::Category::GRAPHICS);\
- BeforeGLCall(MOZ_FUNCTION_NAME)
-#else
-#define BEFORE_GL_CALL do { \
- BeforeGLCall(MOZ_FUNCTION_NAME); \
-} while (0)
-#endif
-
-#define AFTER_GL_CALL do { \
- AfterGLCall(MOZ_FUNCTION_NAME); \
-} while (0)
-#else
-#ifdef MOZ_WIDGET_ANDROID
-// Record the name of the GL call for better hang stacks on Android.
-#define BEFORE_GL_CALL PROFILER_LABEL_FUNC(js::ProfileEntry::Category::GRAPHICS)
-#else
-#define BEFORE_GL_CALL
-#endif
-#define AFTER_GL_CALL
-#endif
-
-class GLContext;
+void BeforeEGLCall(const char* funcName);
+void AfterEGLCall(const char* funcName);
class GLLibraryEGL
{
public:
GLLibraryEGL()
: mSymbols{nullptr}
, mInitialized(false)
, mEGLLibrary(nullptr)
@@ -156,337 +119,187 @@ public:
protected:
std::bitset<Extensions_Max> mAvailableExtensions;
public:
GLLibraryLoader::PlatformLookupFunction GetLookupFunction() const {
return (GLLibraryLoader::PlatformLookupFunction)mSymbols.fGetProcAddress;
}
- EGLDisplay fGetDisplay(void* display_id)
- {
- BEFORE_GL_CALL;
- EGLDisplay disp = mSymbols.fGetDisplay(display_id);
- AFTER_GL_CALL;
- return disp;
- }
-
- EGLDisplay fGetPlatformDisplayEXT(EGLenum platform, void* native_display, const EGLint* attrib_list)
- {
- BEFORE_GL_CALL;
- EGLDisplay disp = mSymbols.fGetPlatformDisplayEXT(platform, native_display, attrib_list);
- AFTER_GL_CALL;
- return disp;
- }
+ ////
- EGLBoolean fTerminate(EGLDisplay display)
- {
- BEFORE_GL_CALL;
- EGLBoolean ret = mSymbols.fTerminate(display);
- AFTER_GL_CALL;
- return ret;
- }
-
- EGLSurface fGetCurrentSurface(EGLint id)
- {
- BEFORE_GL_CALL;
- EGLSurface surf = mSymbols.fGetCurrentSurface(id);
- AFTER_GL_CALL;
- return surf;
- }
+#ifdef MOZ_WIDGET_ANDROID
+#define PROFILE_CALL PROFILER_LABEL_FUNC(js::ProfileEntry::Category::GRAPHICS);
+#else
+#define PROFILE_CALL
+#endif
- EGLContext fGetCurrentContext()
- {
- BEFORE_GL_CALL;
- EGLContext context = mSymbols.fGetCurrentContext();
- AFTER_GL_CALL;
- return context;
- }
-
- EGLBoolean fMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx)
- {
- BEFORE_GL_CALL;
- EGLBoolean b = mSymbols.fMakeCurrent(dpy, draw, read, ctx);
- AFTER_GL_CALL;
- return b;
- }
+#ifndef MOZ_FUNCTION_NAME
+# ifdef __GNUC__
+# define MOZ_FUNCTION_NAME __PRETTY_FUNCTION__
+# elif defined(_MSC_VER)
+# define MOZ_FUNCTION_NAME __FUNCTION__
+# else
+# define MOZ_FUNCTION_NAME __func__ // defined in C99, supported in various C++ compilers. Just raw function name.
+# endif
+#endif
- EGLBoolean fDestroyContext(EGLDisplay dpy, EGLContext ctx)
- {
- BEFORE_GL_CALL;
- EGLBoolean b = mSymbols.fDestroyContext(dpy, ctx);
- AFTER_GL_CALL;
- return b;
- }
+#ifdef DEBUG
+#define BEFORE_CALL BeforeEGLCall(MOZ_FUNCTION_NAME);
+#define AFTER_CALL AfterEGLCall(MOZ_FUNCTION_NAME);
+#else
+#define BEFORE_CALL
+#define AFTER_CALL
+#endif
- EGLContext fCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint* attrib_list)
- {
- BEFORE_GL_CALL;
- EGLContext ctx = mSymbols.fCreateContext(dpy, config, share_context, attrib_list);
- AFTER_GL_CALL;
- return ctx;
- }
-
- EGLBoolean fDestroySurface(EGLDisplay dpy, EGLSurface surface)
- {
- BEFORE_GL_CALL;
- EGLBoolean b = mSymbols.fDestroySurface(dpy, surface);
- AFTER_GL_CALL;
- return b;
+#define WRAP(X) \
+ { \
+ PROFILE_CALL \
+ BEFORE_CALL \
+ const auto ret = mSymbols. X ; \
+ AFTER_CALL \
+ return ret; \
}
- EGLSurface fCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint* attrib_list)
- {
- BEFORE_GL_CALL;
- EGLSurface surf = mSymbols.fCreateWindowSurface(dpy, config, win, attrib_list);
- AFTER_GL_CALL;
- return surf;
- }
-
- EGLSurface fCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint* attrib_list)
- {
- BEFORE_GL_CALL;
- EGLSurface surf = mSymbols.fCreatePbufferSurface(dpy, config, attrib_list);
- AFTER_GL_CALL;
- return surf;
- }
-
- EGLSurface fCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list)
- {
- BEFORE_GL_CALL;
- EGLSurface ret = mSymbols.fCreatePbufferFromClientBuffer(dpy, buftype, buffer, config, attrib_list);
- AFTER_GL_CALL;
- return ret;
- }
-
- EGLSurface fCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint* attrib_list)
- {
- BEFORE_GL_CALL;
- EGLSurface surf = mSymbols.fCreatePixmapSurface(dpy, config, pixmap, attrib_list);
- AFTER_GL_CALL;
- return surf;
- }
-
- EGLBoolean fBindAPI(EGLenum api)
- {
- BEFORE_GL_CALL;
- EGLBoolean b = mSymbols.fBindAPI(api);
- AFTER_GL_CALL;
- return b;
- }
-
- EGLBoolean fInitialize(EGLDisplay dpy, EGLint* major, EGLint* minor)
- {
- BEFORE_GL_CALL;
- EGLBoolean b = mSymbols.fInitialize(dpy, major, minor);
- AFTER_GL_CALL;
- return b;
- }
-
- EGLBoolean fChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, EGLint config_size, EGLint* num_config)
- {
- BEFORE_GL_CALL;
- EGLBoolean b = mSymbols.fChooseConfig(dpy, attrib_list, configs, config_size, num_config);
- AFTER_GL_CALL;
- return b;
- }
-
- EGLint fGetError()
- {
- BEFORE_GL_CALL;
- EGLint i = mSymbols.fGetError();
- AFTER_GL_CALL;
- return i;
- }
-
- EGLBoolean fGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint* value)
- {
- BEFORE_GL_CALL;
- EGLBoolean b = mSymbols.fGetConfigAttrib(dpy, config, attribute, value);
- AFTER_GL_CALL;
- return b;
- }
-
- EGLBoolean fGetConfigs(EGLDisplay dpy, EGLConfig* configs, EGLint config_size, EGLint* num_config)
- {
- BEFORE_GL_CALL;
- EGLBoolean b = mSymbols.fGetConfigs(dpy, configs, config_size, num_config);
- AFTER_GL_CALL;
- return b;
- }
-
- EGLBoolean fWaitNative(EGLint engine)
- {
- BEFORE_GL_CALL;
- EGLBoolean b = mSymbols.fWaitNative(engine);
- AFTER_GL_CALL;
- return b;
+#define VOID_WRAP(X) \
+ { \
+ PROFILE_CALL \
+ BEFORE_CALL \
+ mSymbols. X ; \
+ AFTER_CALL \
}
- EGLCastToRelevantPtr fGetProcAddress(const char* procname)
- {
- BEFORE_GL_CALL;
- EGLCastToRelevantPtr p = mSymbols.fGetProcAddress(procname);
- AFTER_GL_CALL;
- return p;
- }
+ EGLDisplay fGetDisplay(void* display_id) const
+ WRAP( fGetDisplay(display_id) )
+
+ EGLDisplay fGetPlatformDisplayEXT(EGLenum platform, void* native_display, const EGLint* attrib_list) const
+ WRAP( fGetPlatformDisplayEXT(platform, native_display, attrib_list) )
- EGLBoolean fSwapBuffers(EGLDisplay dpy, EGLSurface surface)
- {
- BEFORE_GL_CALL;
- EGLBoolean b = mSymbols.fSwapBuffers(dpy, surface);
- AFTER_GL_CALL;
- return b;
- }
+ EGLBoolean fTerminate(EGLDisplay display) const
+ WRAP( fTerminate(display) )
+
+ EGLSurface fGetCurrentSurface(EGLint id) const
+ WRAP( fGetCurrentSurface(id) )
+
+ EGLContext fGetCurrentContext() const
+ WRAP( fGetCurrentContext() )
- EGLBoolean fCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target)
- {
- BEFORE_GL_CALL;
- EGLBoolean b = mSymbols.fCopyBuffers(dpy, surface, target);
- AFTER_GL_CALL;
- return b;
- }
+ EGLBoolean fMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) const
+ WRAP( fMakeCurrent(dpy, draw, read, ctx) )
+
+ EGLBoolean fDestroyContext(EGLDisplay dpy, EGLContext ctx) const
+ WRAP( fDestroyContext(dpy, ctx) )
- const GLubyte* fQueryString(EGLDisplay dpy, EGLint name)
- {
- BEFORE_GL_CALL;
- const auto ret = mSymbols.fQueryString(dpy, name);
- AFTER_GL_CALL;
- return ret;
- }
+ EGLContext fCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint* attrib_list) const
+ WRAP( fCreateContext(dpy, config, share_context, attrib_list) )
- EGLBoolean fQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint* value)
- {
- BEFORE_GL_CALL;
- EGLBoolean b = mSymbols.fQueryContext(dpy, ctx, attribute, value);
- AFTER_GL_CALL;
- return b;
- }
+ EGLBoolean fDestroySurface(EGLDisplay dpy, EGLSurface surface) const
+ WRAP( fDestroySurface(dpy, surface) )
+
+ EGLSurface fCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint* attrib_list) const
+ WRAP( fCreateWindowSurface(dpy, config, win, attrib_list) )
- EGLBoolean fBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
- {
- BEFORE_GL_CALL;
- EGLBoolean b = mSymbols.fBindTexImage(dpy, surface, buffer);
- AFTER_GL_CALL;
- return b;
- }
+ EGLSurface fCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint* attrib_list) const
+ WRAP( fCreatePbufferSurface(dpy, config, attrib_list) )
+
+ EGLSurface fCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list) const
+ WRAP( fCreatePbufferFromClientBuffer(dpy, buftype, buffer, config, attrib_list) )
- EGLBoolean fReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
- {
- BEFORE_GL_CALL;
- EGLBoolean b = mSymbols.fReleaseTexImage(dpy, surface, buffer);
- AFTER_GL_CALL;
- return b;
- }
+ EGLSurface fCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint* attrib_list) const
+ WRAP( fCreatePixmapSurface(dpy, config, pixmap, attrib_list) )
+
+ EGLBoolean fBindAPI(EGLenum api) const
+ WRAP( fBindAPI(api) )
+
+ EGLBoolean fInitialize(EGLDisplay dpy, EGLint* major, EGLint* minor) const
+ WRAP( fInitialize(dpy, major, minor) )
- EGLImage fCreateImage(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint* attrib_list)
- {
- BEFORE_GL_CALL;
- EGLImage i = mSymbols.fCreateImageKHR(dpy, ctx, target, buffer, attrib_list);
- AFTER_GL_CALL;
- return i;
- }
+ EGLBoolean fChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, EGLint config_size, EGLint* num_config) const
+ WRAP( fChooseConfig(dpy, attrib_list, configs, config_size, num_config) )
+
+ EGLint fGetError() const
+ WRAP( fGetError() )
+
+ EGLBoolean fGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint* value) const
+ WRAP( fGetConfigAttrib(dpy, config, attribute, value) )
- EGLBoolean fDestroyImage(EGLDisplay dpy, EGLImage image)
- {
- BEFORE_GL_CALL;
- EGLBoolean b = mSymbols.fDestroyImageKHR(dpy, image);
- AFTER_GL_CALL;
- return b;
- }
+ EGLBoolean fGetConfigs(EGLDisplay dpy, EGLConfig* configs, EGLint config_size, EGLint* num_config) const
+ WRAP( fGetConfigs(dpy, configs, config_size, num_config) )
- // New extension which allow us to lock texture and get raw image pointer
- EGLBoolean fLockSurface(EGLDisplay dpy, EGLSurface surface, const EGLint* attrib_list)
- {
- BEFORE_GL_CALL;
- EGLBoolean b = mSymbols.fLockSurfaceKHR(dpy, surface, attrib_list);
- AFTER_GL_CALL;
- return b;
- }
+ EGLBoolean fWaitNative(EGLint engine) const
+ WRAP( fWaitNative(engine) )
+
+ EGLCastToRelevantPtr fGetProcAddress(const char* procname) const
+ WRAP( fGetProcAddress(procname) )
- EGLBoolean fUnlockSurface(EGLDisplay dpy, EGLSurface surface)
- {
- BEFORE_GL_CALL;
- EGLBoolean b = mSymbols.fUnlockSurfaceKHR(dpy, surface);
- AFTER_GL_CALL;
- return b;
- }
+ EGLBoolean fSwapBuffers(EGLDisplay dpy, EGLSurface surface) const
+ WRAP( fSwapBuffers(dpy, surface) )
+
+ EGLBoolean fCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) const
+ WRAP( fCopyBuffers(dpy, surface, target) )
- EGLBoolean fQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint* value)
- {
- BEFORE_GL_CALL;
- EGLBoolean b = mSymbols.fQuerySurface(dpy, surface, attribute, value);
- AFTER_GL_CALL;
- return b;
- }
+ const GLubyte* fQueryString(EGLDisplay dpy, EGLint name) const
+ WRAP( fQueryString(dpy, name) )
+
+ EGLBoolean fQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint* value) const
+ WRAP( fQueryContext(dpy, ctx, attribute, value) )
+
+ EGLBoolean fBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) const
+ WRAP( fBindTexImage(dpy, surface, buffer) )
- EGLBoolean fQuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surface, EGLint attribute, void** value)
- {
- BEFORE_GL_CALL;
- EGLBoolean b = mSymbols.fQuerySurfacePointerANGLE(dpy, surface, attribute, value);
- AFTER_GL_CALL;
- return b;
- }
+ EGLBoolean fReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) const
+ WRAP( fReleaseTexImage(dpy, surface, buffer) )
+
+ EGLImage fCreateImage(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint* attrib_list) const
+ WRAP( fCreateImageKHR(dpy, ctx, target, buffer, attrib_list) )
+
+ EGLBoolean fDestroyImage(EGLDisplay dpy, EGLImage image) const
+ WRAP( fDestroyImageKHR(dpy, image) )
- EGLSync fCreateSync(EGLDisplay dpy, EGLenum type, const EGLint* attrib_list)
- {
- BEFORE_GL_CALL;
- EGLSync ret = mSymbols.fCreateSyncKHR(dpy, type, attrib_list);
- AFTER_GL_CALL;
- return ret;
- }
+ EGLBoolean fLockSurface(EGLDisplay dpy, EGLSurface surface, const EGLint* attrib_list) const
+ WRAP( fLockSurfaceKHR(dpy, surface, attrib_list) )
- EGLBoolean fDestroySync(EGLDisplay dpy, EGLSync sync)
- {
- BEFORE_GL_CALL;
- EGLBoolean b = mSymbols.fDestroySyncKHR(dpy, sync);
- AFTER_GL_CALL;
- return b;
- }
+ EGLBoolean fUnlockSurface(EGLDisplay dpy, EGLSurface surface) const
+ WRAP( fUnlockSurfaceKHR(dpy, surface) )
+
+ EGLBoolean fQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint* value) const
+ WRAP( fQuerySurface(dpy, surface, attribute, value) )
- EGLint fClientWaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout)
- {
- BEFORE_GL_CALL;
- EGLint ret = mSymbols.fClientWaitSyncKHR(dpy, sync, flags, timeout);
- AFTER_GL_CALL;
- return ret;
- }
+ EGLBoolean fQuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surface, EGLint attribute, void** value) const
+ WRAP( fQuerySurfacePointerANGLE(dpy, surface, attribute, value) )
+
+ EGLSync fCreateSync(EGLDisplay dpy, EGLenum type, const EGLint* attrib_list) const
+ WRAP( fCreateSyncKHR(dpy, type, attrib_list) )
- EGLBoolean fGetSyncAttrib(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLint* value)
- {
- BEFORE_GL_CALL;
- EGLBoolean b = mSymbols.fGetSyncAttribKHR(dpy, sync, attribute, value);
- AFTER_GL_CALL;
- return b;
- }
+ EGLBoolean fDestroySync(EGLDisplay dpy, EGLSync sync) const
+ WRAP( fDestroySyncKHR(dpy, sync) )
+
+ EGLint fClientWaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout) const
+ WRAP( fClientWaitSyncKHR(dpy, sync, flags, timeout) )
+
+ EGLBoolean fGetSyncAttrib(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLint* value) const
+ WRAP( fGetSyncAttribKHR(dpy, sync, attribute, value) )
- EGLint fDupNativeFenceFDANDROID(EGLDisplay dpy, EGLSync sync)
- {
- MOZ_ASSERT(mSymbols.fDupNativeFenceFDANDROID);
- BEFORE_GL_CALL;
- EGLint ret = mSymbols.fDupNativeFenceFDANDROID(dpy, sync);
- AFTER_GL_CALL;
- return ret;
- }
+ EGLint fDupNativeFenceFDANDROID(EGLDisplay dpy, EGLSync sync) const
+ WRAP( fDupNativeFenceFDANDROID(dpy, sync) )
+
+ void fANGLEPlatformInitialize(angle::Platform* platform) const
+ VOID_WRAP( fANGLEPlatformInitialize(platform) )
+
+ void fANGLEPlatformShutdown() const
+ VOID_WRAP( fANGLEPlatformShutdown() )
- void fANGLEPlatformInitialize(angle::Platform* platform)
- {
- MOZ_ASSERT(mSymbols.fANGLEPlatformInitialize);
- BEFORE_GL_CALL;
- mSymbols.fANGLEPlatformInitialize(platform);
- AFTER_GL_CALL;
- }
+#undef WRAP
+#undef VOID_WRAP
+#undef PROFILE_CALL
+#undef BEFORE_CALL
+#undef AFTER_CALL
+#undef MOZ_FUNCTION_NAME
- void fANGLEPlatformShutdown()
- {
- MOZ_ASSERT(mSymbols.fANGLEPlatformShutdown);
- BEFORE_GL_CALL;
- mSymbols.fANGLEPlatformShutdown();
- AFTER_GL_CALL;
- }
+ ////
EGLDisplay Display() {
MOZ_ASSERT(mInitialized);
return mEGLDisplay;
}
bool IsANGLE() const {
MOZ_ASSERT(mInitialized);
@@ -599,21 +412,16 @@ private:
EGLTime timeout);
EGLBoolean (GLAPIENTRY * fGetSyncAttribKHR)(EGLDisplay dpy, EGLSync sync,
EGLint attribute, EGLint* value);
EGLint (GLAPIENTRY * fDupNativeFenceFDANDROID)(EGLDisplay dpy, EGLSync sync);
void (GLAPIENTRY * fANGLEPlatformInitialize)(angle::Platform* platform);
void (GLAPIENTRY * fANGLEPlatformShutdown)();
} mSymbols;
-#ifdef DEBUG
- static void BeforeGLCall(const char* glFunction);
- static void AfterGLCall(const char* glFunction);
-#endif
-
public:
#ifdef MOZ_B2G
EGLContext CachedCurrentContext() {
return sCurrentContext.get();
}
void UnsetCachedCurrentContext() {
sCurrentContext.set(nullptr);
}
--- a/gfx/gl/GLXLibrary.h
+++ b/gfx/gl/GLXLibrary.h
@@ -38,84 +38,130 @@ public:
, mHasRobustness(false)
, mHasCreateContextAttribs(false)
, mHasVideoSync(false)
, mIsATI(false), mIsNVIDIA(false)
, mClientIsMesa(false)
, mOGLLibrary(nullptr)
{}
- void xDestroyContext(Display* display, GLXContext context);
- Bool xMakeCurrent(Display* display,
- GLXDrawable drawable,
- GLXContext context);
+ bool EnsureInitialized();
+
+private:
+ void BeforeGLXCall() const;
+ void AfterGLXCall() const;
+
+public:
+
+#ifdef DEBUG
+#define BEFORE_CALL BeforeGLXCall();
+#define AFTER_CALL AfterGLXCall();
+#else
+#define BEFORE_CALL
+#define AFTER_CALL
+#endif
+
+#define WRAP(X) \
+ { \
+ BEFORE_CALL \
+ const auto ret = mSymbols. X ; \
+ AFTER_CALL \
+ return ret; \
+ }
+#define VOID_WRAP(X) \
+ { \
+ BEFORE_CALL \
+ mSymbols. X ; \
+ AFTER_CALL \
+ }
+
+ void fDestroyContext(Display* display, GLXContext context) const
+ VOID_WRAP( fDestroyContext(display, context) )
+
+ Bool fMakeCurrent(Display* display, GLXDrawable drawable, GLXContext context) const
+ WRAP( fMakeCurrent(display, drawable, context) )
+
+ GLXContext fGetCurrentContext() const
+ WRAP( fGetCurrentContext() )
+
+ GLXFBConfig* fChooseFBConfig(Display* display, int screen, const int* attrib_list, int* nelements) const
+ WRAP( fChooseFBConfig(display, screen, attrib_list, nelements) )
+
+ GLXFBConfig* fGetFBConfigs(Display* display, int screen, int* nelements) const
+ WRAP( fGetFBConfigs(display, screen, nelements) )
+
+ GLXContext fCreateNewContext(Display* display, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct) const
+ WRAP( fCreateNewContext(display, config, render_type, share_list, direct) )
+
+ int fGetFBConfigAttrib(Display* display, GLXFBConfig config, int attribute, int* value) const
+ WRAP( fGetFBConfigAttrib(display, config, attribute, value) )
- GLXContext xGetCurrentContext();
- 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();
- void xWaitX();
+ void fSwapBuffers(Display* display, GLXDrawable drawable) const
+ VOID_WRAP( fSwapBuffers(display, drawable) )
+
+ const char* fQueryExtensionsString(Display* display, int screen) const
+ WRAP( fQueryExtensionsString(display, screen) )
+
+ const char* fGetClientString(Display* display, int screen) const
+ WRAP( fGetClientString(display, screen) )
+
+ const char* fQueryServerString(Display* display, int screen, int name) const
+ WRAP( fQueryServerString(display, screen, name) )
+
+ GLXPixmap fCreatePixmap(Display* display, GLXFBConfig config, Pixmap pixmap, const int* attrib_list) const
+ WRAP( fCreatePixmap(display, config, pixmap, attrib_list) )
+
+ GLXPixmap fCreateGLXPixmapWithConfig(Display* display, GLXFBConfig config, Pixmap pixmap) const
+ WRAP( fCreateGLXPixmapWithConfig(display, config, pixmap) )
+
+ void fDestroyPixmap(Display* display, GLXPixmap pixmap) const
+ VOID_WRAP( fDestroyPixmap(display, pixmap) )
+
+ Bool fQueryVersion(Display* display, int* major, int* minor) const
+ WRAP( fQueryVersion(display, major, minor) )
+
+ void fBindTexImage(Display* display, GLXDrawable drawable, int buffer, const int* attrib_list) const
+ VOID_WRAP( fBindTexImageEXT(display, drawable, buffer, attrib_list) )
- GLXContext xCreateContextAttribs(Display* display,
- GLXFBConfig config,
- GLXContext share_list,
- Bool direct,
- const int* attrib_list);
+ void fReleaseTexImage(Display* display, GLXDrawable drawable, int buffer) const
+ VOID_WRAP( fReleaseTexImageEXT(display, drawable, buffer) )
+
+ void fWaitGL() const
+ VOID_WRAP( fWaitGL() )
+
+ void fWaitX() const
+ VOID_WRAP( fWaitX() )
+
+ GLXContext fCreateContextAttribs(Display* display, GLXFBConfig config, GLXContext share_list, Bool direct, const int* attrib_list) const
+ WRAP( fCreateContextAttribsARB(display, config, share_list, direct, attrib_list) )
- int xGetVideoSync(unsigned int* count);
- int xWaitVideoSync(int divisor, int remainder, unsigned int* count);
- void xSwapInterval(Display* dpy, GLXDrawable drawable, int interval);
+ int fGetVideoSync(unsigned int* count) const
+ WRAP( fGetVideoSyncSGI(count) )
+
+ int fWaitVideoSync(int divisor, int remainder, unsigned int* count) const
+ WRAP( fWaitVideoSyncSGI(divisor, remainder, count) )
- bool EnsureInitialized();
+ void fSwapInterval(Display* dpy, GLXDrawable drawable, int interval) const
+ VOID_WRAP( fSwapIntervalEXT(dpy, drawable, interval) )
+
+#undef WRAP
+#undef VOID_WRAP
+#undef BEFORE_CALL
+#undef AFTER_CALL
+
+ ////
GLXPixmap CreatePixmap(gfxASurface* aSurface);
void DestroyPixmap(Display* aDisplay, GLXPixmap aPixmap);
void BindTexImage(Display* aDisplay, GLXPixmap aPixmap);
void ReleaseTexImage(Display* aDisplay, GLXPixmap aPixmap);
void UpdateTexImage(Display* aDisplay, GLXPixmap aPixmap);
+ ////
+
bool UseTextureFromPixmap() { return mUseTextureFromPixmap; }
bool HasRobustness() { return mHasRobustness; }
bool HasCreateContextAttribs() { return mHasCreateContextAttribs; }
bool SupportsTextureFromPixmap(gfxASurface* aSurface);
bool SupportsVideoSync();
bool SupportsSwapControl() const { return bool(mSymbols.fSwapIntervalEXT); }
bool IsATI() { return mIsATI; }
bool IsMesa() { return mClientIsMesa; }
--- a/gfx/thebes/gfxPlatformGtk.cpp
+++ b/gfx/thebes/gfxPlatformGtk.cpp
@@ -758,17 +758,17 @@ public:
lock.NotifyAll();
return;
}
mGLContext->MakeCurrent();
// Test that SGI_video_sync lets us get the counter.
unsigned int syncCounter = 0;
- if (gl::sGLXLibrary.xGetVideoSync(&syncCounter) != 0) {
+ if (gl::sGLXLibrary.fGetVideoSync(&syncCounter) != 0) {
mGLContext = nullptr;
}
lock.NotifyAll();
}
virtual void EnableVsync() override
{
@@ -822,34 +822,34 @@ public:
void RunVsync()
{
MOZ_ASSERT(!NS_IsMainThread());
mGLContext->MakeCurrent();
unsigned int syncCounter = 0;
- gl::sGLXLibrary.xGetVideoSync(&syncCounter);
+ gl::sGLXLibrary.fGetVideoSync(&syncCounter);
for (;;) {
{
MonitorAutoLock lock(mVsyncEnabledLock);
if (!mVsyncEnabled) {
mVsyncTask = nullptr;
return;
}
}
TimeStamp lastVsync = TimeStamp::Now();
bool useSoftware = false;
// Wait until the video sync counter reaches the next value by waiting
// until the parity of the counter value changes.
unsigned int nextSync = syncCounter + 1;
int status;
- if ((status = gl::sGLXLibrary.xWaitVideoSync(2, nextSync % 2, &syncCounter)) != 0) {
+ if ((status = gl::sGLXLibrary.fWaitVideoSync(2, nextSync % 2, &syncCounter)) != 0) {
gfxWarningOnce() << "glXWaitVideoSync returned " << status;
useSoftware = true;
}
if (syncCounter == (nextSync - 1)) {
gfxWarningOnce() << "glXWaitVideoSync failed to increment the sync counter.";
useSoftware = true;
}