OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2015 Google Inc. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license that can be | |
5 * found in the LICENSE file. | |
6 * | |
7 */ | |
8 | |
9 #include "GrNativeDisplay_glx.h" | |
10 | |
11 #include "SkTypes.h" | |
12 | |
13 namespace GrNativeDisplay { | |
14 | |
robertphillips
2015/10/16 14:54:40
const int* visualAttribs ?
| |
15 bool Initialize(int* visualAttribs, Display* display, GLXFBConfig* bestConfig) { | |
16 SkASSERT(visualAttribs && display && bestConfig); | |
robertphillips
2015/10/16 14:54:40
glxMajor, glxMinor ?
Do we even need the glx ?
| |
17 int glx_major, glx_minor; | |
18 | |
19 // FBConfigs were added in GLX version 1.3. | |
20 if (!glXQueryVersion(display, &glx_major, &glx_minor) || | |
21 ((glx_major == 1) && (glx_minor < 3)) || (glx_major < 1)) { | |
22 SkDebugf("GLX version 1.3 or higher required.\n"); | |
23 return false; | |
24 } | |
25 | |
26 //SkDebugf("Getting matching framebuffer configs.\n"); | |
27 int fbcount; | |
28 GLXFBConfig *fbc = glXChooseFBConfig(display, DefaultScreen(display), | |
29 visualAttribs, &fbcount); | |
30 if (!fbc) { | |
31 SkDebugf("Failed to retrieve a framebuffer config.\n"); | |
32 return false; | |
33 } | |
34 //SkDebugf("Found %d matching FB configs.\n", fbcount); | |
35 | |
36 // Pick the FB config/visual with the most samples per pixel | |
37 //SkDebugf("Getting XVisualInfos.\n"); | |
robertphillips
2015/10/16 14:54:40
bestFBC, maxNumSamples ?
| |
38 int best_fbc = -1, best_num_samp = -1; | |
39 | |
40 int i; | |
41 for (i = 0; i < fbcount; ++i) { | |
42 XVisualInfo *vi = glXGetVisualFromFBConfig(display, fbc[i]); | |
43 if (vi) { | |
robertphillips
2015/10/16 14:54:40
sampleBuffers ?
| |
44 int samp_buf, samples; | |
45 glXGetFBConfigAttrib(display, fbc[i], GLX_SAMPLE_BUFFERS, &samp_buf) ; | |
46 glXGetFBConfigAttrib(display, fbc[i], GLX_SAMPLES, &samples); | |
47 | |
48 //SkDebugf(" Matching fbconfig %d, visual ID 0x%2x: SAMPLE_BUFFERS = %d," | |
49 // " SAMPLES = %d\n", | |
50 // i, (unsigned int)vi->visualid, samp_buf, samples); | |
51 | |
robertphillips
2015/10/16 14:54:40
add {} to this ?
| |
52 if (best_fbc < 0 || (samp_buf && samples > best_num_samp)) | |
53 best_fbc = i, best_num_samp = samples; | |
54 } | |
55 XFree(vi); | |
56 } | |
57 | |
58 *bestConfig = fbc[best_fbc]; | |
59 | |
60 // Be sure to free the FBConfig list allocated by glXChooseFBConfig() | |
61 XFree(fbc); | |
62 return true; | |
63 } | |
64 | |
65 }; | |
OLD | NEW |