From ef77e8b65149a29a541044239fccf5e14b95e94d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 26 Apr 2011 16:21:58 +0200 Subject: Added QWindowContext and got wiggly up and running with xcb. (cherry picked from commit c980e4ef4ebc7699a6c3a7529d3f08ebafc21ffe) --- .../platforms/glxconvenience/qglxconvenience.cpp | 99 +++++++--------------- 1 file changed, 31 insertions(+), 68 deletions(-) (limited to 'src/plugins/platforms/glxconvenience/qglxconvenience.cpp') diff --git a/src/plugins/platforms/glxconvenience/qglxconvenience.cpp b/src/plugins/platforms/glxconvenience/qglxconvenience.cpp index 7cee3e2ea1..abf7b83e04 100644 --- a/src/plugins/platforms/glxconvenience/qglxconvenience.cpp +++ b/src/plugins/platforms/glxconvenience/qglxconvenience.cpp @@ -66,7 +66,7 @@ enum { #undef FontChange #endif -QVector qglx_buildSpec(const QPlatformWindowFormat &format, int drawableBit) +QVector qglx_buildSpec(const QWindowFormat &format, int drawableBit) { QVector spec(48); int i = 0; @@ -75,54 +75,37 @@ QVector qglx_buildSpec(const QPlatformWindowFormat &format, int drawableBit spec[i++] = 0; spec[i++] = GLX_DRAWABLE_TYPE; spec[i++] = drawableBit; - if (format.rgba()) { - spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_RGBA_BIT; - spec[i++] = GLX_RED_SIZE; spec[i++] = (format.redBufferSize() == -1) ? 1 : format.redBufferSize(); - spec[i++] = GLX_GREEN_SIZE; spec[i++] = (format.greenBufferSize() == -1) ? 1 : format.greenBufferSize(); - spec[i++] = GLX_BLUE_SIZE; spec[i++] = (format.blueBufferSize() == -1) ? 1 : format.blueBufferSize(); - if (format.alpha()) { - spec[i++] = GLX_ALPHA_SIZE; spec[i++] = (format.alphaBufferSize() == -1) ? 1 : format.alphaBufferSize(); - } - - spec[i++] = GLX_ACCUM_RED_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize(); - spec[i++] = GLX_ACCUM_GREEN_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize(); - spec[i++] = GLX_ACCUM_BLUE_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize(); - - if (format.alpha()) { - spec[i++] = GLX_ACCUM_ALPHA_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize(); - } - - } else { - spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_COLOR_INDEX_BIT; //I'm really not sure if this works.... - spec[i++] = GLX_BUFFER_SIZE; spec[i++] = 8; + spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_RGBA_BIT; + spec[i++] = GLX_RED_SIZE; spec[i++] = (format.redBufferSize() == -1) ? 1 : format.redBufferSize(); + spec[i++] = GLX_GREEN_SIZE; spec[i++] = (format.greenBufferSize() == -1) ? 1 : format.greenBufferSize(); + spec[i++] = GLX_BLUE_SIZE; spec[i++] = (format.blueBufferSize() == -1) ? 1 : format.blueBufferSize(); + if (format.hasAlpha()) { + spec[i++] = GLX_ALPHA_SIZE; spec[i++] = (format.alphaBufferSize() == -1) ? 1 : format.alphaBufferSize(); } - spec[i++] = GLX_DOUBLEBUFFER; spec[i++] = format.doubleBuffer() ? True : False; + spec[i++] = GLX_DOUBLEBUFFER; spec[i++] = format.swapBehavior() != QWindowFormat::SingleBuffer ? True : False; spec[i++] = GLX_STEREO; spec[i++] = format.stereo() ? True : False; - if (format.depth()) { - spec[i++] = GLX_DEPTH_SIZE; spec[i++] = (format.depthBufferSize() == -1) ? 1 : format.depthBufferSize(); - } + spec[i++] = GLX_DEPTH_SIZE; spec[i++] = (format.depthBufferSize() == -1) ? 1 : format.depthBufferSize(); - if (format.stencil()) { - spec[i++] = GLX_STENCIL_SIZE; spec[i++] = (format.stencilBufferSize() == -1) ? 1 : format.stencilBufferSize(); - } - if (format.sampleBuffers()) { + spec[i++] = GLX_STENCIL_SIZE; spec[i++] = (format.stencilBufferSize() == -1) ? 1 : format.stencilBufferSize(); + + if (format.samples() > 1) { spec[i++] = GLX_SAMPLE_BUFFERS_ARB; spec[i++] = 1; spec[i++] = GLX_SAMPLES_ARB; - spec[i++] = format.samples() == -1 ? 4 : format.samples(); + spec[i++] = format.samples(); } spec[i++] = XNone; return spec; } -GLXFBConfig qglx_findConfig(Display *display, int screen , const QPlatformWindowFormat &format, int drawableBit) +GLXFBConfig qglx_findConfig(Display *display, int screen , const QWindowFormat &format, int drawableBit) { bool reduced = true; GLXFBConfig chosenConfig = 0; - QPlatformWindowFormat reducedFormat = format; + QWindowFormat reducedFormat = format; while (!chosenConfig && reduced) { QVector spec = qglx_buildSpec(reducedFormat, drawableBit); int confcount = 0; @@ -133,7 +116,7 @@ GLXFBConfig qglx_findConfig(Display *display, int screen , const QPlatformWindow for (int i = 0; i < confcount; i++) { chosenConfig = configs[i]; // Make sure we try to get an ARGB visual if the format asked for an alpha: - if (reducedFormat.alpha()) { + if (reducedFormat.hasAlpha()) { int alphaSize; glXGetFBConfigAttrib(display,configs[i],GLX_ALPHA_SIZE,&alphaSize); if (alphaSize > 0) @@ -145,7 +128,7 @@ GLXFBConfig qglx_findConfig(Display *display, int screen , const QPlatformWindow XFree(configs); } - reducedFormat = qglx_reducePlatformWindowFormat(reducedFormat,&reduced); + reducedFormat = qglx_reduceWindowFormat(reducedFormat,&reduced); } if (!chosenConfig) @@ -154,16 +137,16 @@ GLXFBConfig qglx_findConfig(Display *display, int screen , const QPlatformWindow return chosenConfig; } -XVisualInfo *qglx_findVisualInfo(Display *display, int screen, const QPlatformWindowFormat &format) +XVisualInfo *qglx_findVisualInfo(Display *display, int screen, const QWindowFormat &format) { GLXFBConfig config = qglx_findConfig(display,screen,format); XVisualInfo *visualInfo = glXGetVisualFromFBConfig(display,config); return visualInfo; } -QPlatformWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext ctx) +QWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext) { - QPlatformWindowFormat format; + QWindowFormat format; int redSize = 0; int greenSize = 0; int blueSize = 0; @@ -172,16 +155,9 @@ QPlatformWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFB int stencilSize = 0; int sampleBuffers = 0; int sampleCount = 0; - int level = 0; - int rgba = 0; int stereo = 0; - int accumSizeA = 0; - int accumSizeR = 0; - int accumSizeG = 0; - int accumSizeB = 0; XVisualInfo *vi = glXGetVisualFromFBConfig(display,config); - glXGetConfig(display,vi,GLX_RGBA,&rgba); XFree(vi); glXGetFBConfigAttrib(display, config, GLX_RED_SIZE, &redSize); glXGetFBConfigAttrib(display, config, GLX_GREEN_SIZE, &greenSize); @@ -190,12 +166,7 @@ QPlatformWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFB glXGetFBConfigAttrib(display, config, GLX_DEPTH_SIZE, &depthSize); glXGetFBConfigAttrib(display, config, GLX_STENCIL_SIZE, &stencilSize); glXGetFBConfigAttrib(display, config, GLX_SAMPLES, &sampleBuffers); - glXGetFBConfigAttrib(display, config, GLX_LEVEL, &level); glXGetFBConfigAttrib(display, config, GLX_STEREO, &stereo); - glXGetFBConfigAttrib(display, config, GLX_ACCUM_ALPHA_SIZE, &accumSizeA); - glXGetFBConfigAttrib(display, config, GLX_ACCUM_RED_SIZE, &accumSizeR); - glXGetFBConfigAttrib(display, config, GLX_ACCUM_GREEN_SIZE, &accumSizeG); - glXGetFBConfigAttrib(display, config, GLX_ACCUM_BLUE_SIZE, &accumSizeB); format.setRedBufferSize(redSize); format.setGreenBufferSize(greenSize); @@ -203,39 +174,31 @@ QPlatformWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFB format.setAlphaBufferSize(alphaSize); format.setDepthBufferSize(depthSize); format.setStencilBufferSize(stencilSize); - format.setSampleBuffers(sampleBuffers); - if (format.sampleBuffers()) { + if (sampleBuffers) { glXGetFBConfigAttrib(display, config, GLX_SAMPLES_ARB, &sampleCount); format.setSamples(sampleCount); } - format.setDirectRendering(glXIsDirect(display, ctx)); - format.setRgba(rgba); format.setStereo(stereo); - format.setAccumBufferSize(accumSizeB); return format; } -QPlatformWindowFormat qglx_reducePlatformWindowFormat(const QPlatformWindowFormat &format, bool *reduced) +QWindowFormat qglx_reduceWindowFormat(const QWindowFormat &format, bool *reduced) { - QPlatformWindowFormat retFormat = format; + QWindowFormat retFormat = format; *reduced = true; - if (retFormat.sampleBuffers()) { - retFormat.setSampleBuffers(false); + if (retFormat.samples() > 1) { + retFormat.setSamples(0); } else if (retFormat.stereo()) { retFormat.setStereo(false); - } else if (retFormat.accum()) { - retFormat.setAccum(false); - }else if (retFormat.stencil()) { - retFormat.setStencil(false); - }else if (retFormat.alpha()) { - retFormat.setAlpha(false); - }else if (retFormat.depth()) { - retFormat.setDepth(false); - }else if (retFormat.doubleBuffer()) { - retFormat.setDoubleBuffer(false); + }else if (retFormat.stencilBufferSize() > 0) { + retFormat.setStencilBufferSize(0); + }else if (retFormat.hasAlpha()) { + retFormat.setAlphaBufferSize(0); + }else if (retFormat.depthBufferSize() > 0) { + retFormat.setDepthBufferSize(0); }else{ *reduced = false; } -- cgit v1.2.3