Bug 1401455 - Add GLContextGLX::FindVisual() r=lsalzman
authorJames Willcox <snorp@snorp.net>
Wed, 14 Mar 2018 11:24:43 -0500
changeset 408590 aa0394eb1c570b6d770af2ca55d82ca5b1809b13
parent 408589 1aa26cb6f9d6b42cc40c2928b2065b771dc99fe8
child 408591 8d73f18bc1a2097f1271d9d3af554cd23bcc9324
push id100986
push userjwillcox@mozilla.com
push dateFri, 16 Mar 2018 22:19:42 +0000
treeherdermozilla-inbound@8d73f18bc1a2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslsalzman
bugs1401455
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1401455 - Add GLContextGLX::FindVisual() r=lsalzman MozReview-Commit-ID: IiInaCEtnIF
gfx/gl/GLContextGLX.h
gfx/gl/GLContextProviderGLX.cpp
--- a/gfx/gl/GLContextGLX.h
+++ b/gfx/gl/GLContextGLX.h
@@ -23,16 +23,20 @@ public:
                     const SurfaceCaps& caps,
                     bool isOffscreen,
                     Display* display,
                     GLXDrawable drawable,
                     GLXFBConfig cfg,
                     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,
                           ScopedXFree<GLXFBConfig>* const out_scopedConfigArr,
                           GLXFBConfig* const out_config, int* const out_visid,
                           bool aWebRender);
 
     ~GLContextGLX();
--- a/gfx/gl/GLContextProviderGLX.cpp
+++ b/gfx/gl/GLContextProviderGLX.cpp
@@ -880,16 +880,44 @@ ChooseConfig(GLXLibrary* glx, Display* d
         *out_visid = visid;
         return true;
     }
 
     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,
                                     GLXFBConfig* const out_config, int* const out_visid,
                                     bool aWebRender)
 {
     ScopedXFree<GLXFBConfig>& cfgs = *out_scopedConfigArr;
     int numConfigs;
     const int webrenderAttribs[] = {