Index: src/gpu/gl/glx/GrNativeDisplay_glx.cpp |
diff --git a/src/gpu/gl/glx/GrNativeDisplay_glx.cpp b/src/gpu/gl/glx/GrNativeDisplay_glx.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b7a6632317af542edc28accbd0f524ae50b0392e |
--- /dev/null |
+++ b/src/gpu/gl/glx/GrNativeDisplay_glx.cpp |
@@ -0,0 +1,65 @@ |
+/* |
+ * Copyright 2015 Google Inc. |
+ * |
+ * Use of this source code is governed by a BSD-style license that can be |
+ * found in the LICENSE file. |
+ * |
+ */ |
+ |
+#include "GrNativeDisplay_glx.h" |
+ |
+#include "SkTypes.h" |
+ |
+namespace GrNativeDisplay { |
+ |
robertphillips
2015/10/16 14:54:40
const int* visualAttribs ?
|
+bool Initialize(int* visualAttribs, Display* display, GLXFBConfig* bestConfig) { |
+ SkASSERT(visualAttribs && display && bestConfig); |
robertphillips
2015/10/16 14:54:40
glxMajor, glxMinor ?
Do we even need the glx ?
|
+ int glx_major, glx_minor; |
+ |
+ // FBConfigs were added in GLX version 1.3. |
+ if (!glXQueryVersion(display, &glx_major, &glx_minor) || |
+ ((glx_major == 1) && (glx_minor < 3)) || (glx_major < 1)) { |
+ SkDebugf("GLX version 1.3 or higher required.\n"); |
+ return false; |
+ } |
+ |
+ //SkDebugf("Getting matching framebuffer configs.\n"); |
+ int fbcount; |
+ GLXFBConfig *fbc = glXChooseFBConfig(display, DefaultScreen(display), |
+ visualAttribs, &fbcount); |
+ if (!fbc) { |
+ SkDebugf("Failed to retrieve a framebuffer config.\n"); |
+ return false; |
+ } |
+ //SkDebugf("Found %d matching FB configs.\n", fbcount); |
+ |
+ // Pick the FB config/visual with the most samples per pixel |
+ //SkDebugf("Getting XVisualInfos.\n"); |
robertphillips
2015/10/16 14:54:40
bestFBC, maxNumSamples ?
|
+ int best_fbc = -1, best_num_samp = -1; |
+ |
+ int i; |
+ for (i = 0; i < fbcount; ++i) { |
+ XVisualInfo *vi = glXGetVisualFromFBConfig(display, fbc[i]); |
+ if (vi) { |
robertphillips
2015/10/16 14:54:40
sampleBuffers ?
|
+ int samp_buf, samples; |
+ glXGetFBConfigAttrib(display, fbc[i], GLX_SAMPLE_BUFFERS, &samp_buf); |
+ glXGetFBConfigAttrib(display, fbc[i], GLX_SAMPLES, &samples); |
+ |
+ //SkDebugf(" Matching fbconfig %d, visual ID 0x%2x: SAMPLE_BUFFERS = %d," |
+ // " SAMPLES = %d\n", |
+ // i, (unsigned int)vi->visualid, samp_buf, samples); |
+ |
robertphillips
2015/10/16 14:54:40
add {} to this ?
|
+ if (best_fbc < 0 || (samp_buf && samples > best_num_samp)) |
+ best_fbc = i, best_num_samp = samples; |
+ } |
+ XFree(vi); |
+ } |
+ |
+ *bestConfig = fbc[best_fbc]; |
+ |
+ // Be sure to free the FBConfig list allocated by glXChooseFBConfig() |
+ XFree(fbc); |
+ return true; |
+} |
+ |
+}; |