Bug 1401455 - Add GLContextGLX::FindVisual() r=lsalzman

MozReview-Commit-ID: IiInaCEtnIF
This commit is contained in:
James Willcox 2018-03-14 11:24:43 -05:00
parent 4e30d2b54d
commit 36df193c10
2 changed files with 32 additions and 0 deletions

View File

@ -28,6 +28,10 @@ public:
bool deleteDrawable,
gfxXlibSurface* pixmap);
static bool
FindVisual(Display* display, int screen, bool useWebRender,
bool useAlpha, int* const out_visualId);
// Finds a GLXFBConfig compatible with the provided window.
static bool
FindFBConfigForWindow(Display* display, int screen, Window window,

View File

@ -884,6 +884,34 @@ ChooseConfig(GLXLibrary* glx, Display* display, int screen, const SurfaceCaps& m
return false;
}
bool
GLContextGLX::FindVisual(Display* display, int screen, bool useWebRender,
bool useAlpha, int* const out_visualId)
{
int attribs[] = {
LOCAL_GLX_RGBA,
LOCAL_GLX_DOUBLEBUFFER,
LOCAL_GLX_RED_SIZE, 8,
LOCAL_GLX_GREEN_SIZE, 8,
LOCAL_GLX_BLUE_SIZE, 8,
LOCAL_GLX_ALPHA_SIZE, useAlpha ? 8 : 0,
LOCAL_GLX_DEPTH_SIZE, useWebRender ? 24 : 0,
LOCAL_GL_NONE
};
if (!sGLXLibrary.EnsureInitialized()) {
return false;
}
XVisualInfo* visuals = sGLXLibrary.fChooseVisual(display, screen, attribs);
if (!visuals) {
return false;
}
*out_visualId = visuals[0].visualid;
return true;
}
bool
GLContextGLX::FindFBConfigForWindow(Display* display, int screen, Window window,
ScopedXFree<GLXFBConfig>* const out_scopedConfigArr,