Advertisement
Guest User

qt5base-eglconvenience-color-depth.patch

a guest
Jun 12th, 2013
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.31 KB | None | 0 0
  1. --- a/src/platformsupport/eglconvenience/qeglconvenience.cpp
  2. +++ b/src/platformsupport/eglconvenience/qeglconvenience.cpp
  3. @@ -42,6 +42,7 @@
  4. #include <QByteArray>
  5.  
  6. #include "qeglconvenience_p.h"
  7. +#include "assert.h"
  8.  
  9. QT_BEGIN_NAMESPACE
  10.  
  11. @@ -212,73 +213,39 @@
  12.  
  13. EGLConfig q_configFromGLFormat(EGLDisplay display, const QSurfaceFormat &format, bool highestPixelFormat, int surfaceType)
  14. {
  15. - EGLConfig cfg = 0;
  16. - QVector<EGLint> configureAttributes = q_createConfigAttributesFromFormat(format);
  17. - configureAttributes.append(EGL_SURFACE_TYPE);
  18. - configureAttributes.append(surfaceType);
  19. -
  20. - configureAttributes.append(EGL_RENDERABLE_TYPE);
  21. - if (format.renderableType() == QSurfaceFormat::OpenVG)
  22. - configureAttributes.append(EGL_OPENVG_BIT);
  23. -#ifdef EGL_VERSION_1_4
  24. - else if (format.renderableType() == QSurfaceFormat::OpenGL)
  25. - configureAttributes.append(EGL_OPENGL_BIT);
  26. -#endif
  27. - else if (format.majorVersion() == 1)
  28. - configureAttributes.append(EGL_OPENGL_ES_BIT);
  29. - else
  30. - configureAttributes.append(EGL_OPENGL_ES2_BIT);
  31. -
  32. - configureAttributes.append(EGL_NONE);
  33. -
  34. - do {
  35. - // Get the number of matching configurations for this set of properties.
  36. - EGLint matching = 0;
  37. - if (!eglChooseConfig(display, configureAttributes.constData(), 0, 0, &matching) || !matching)
  38. - continue;
  39. -
  40. - // If we want the best pixel format, then return the first
  41. - // matching configuration.
  42. - if (highestPixelFormat) {
  43. - eglChooseConfig(display, configureAttributes.constData(), &cfg, 1, &matching);
  44. - if (matching < 1)
  45. - continue;
  46. - return cfg;
  47. - }
  48. -
  49. - // Fetch all of the matching configurations and find the
  50. - // first that matches the pixel format we wanted.
  51. - int i = configureAttributes.indexOf(EGL_RED_SIZE);
  52. - int confAttrRed = configureAttributes.at(i+1);
  53. - i = configureAttributes.indexOf(EGL_GREEN_SIZE);
  54. - int confAttrGreen = configureAttributes.at(i+1);
  55. - i = configureAttributes.indexOf(EGL_BLUE_SIZE);
  56. - int confAttrBlue = configureAttributes.at(i+1);
  57. - i = configureAttributes.indexOf(EGL_ALPHA_SIZE);
  58. - int confAttrAlpha = i == -1 ? 0 : configureAttributes.at(i+1);
  59. -
  60. - EGLint size = matching;
  61. - EGLConfig *configs = new EGLConfig [size];
  62. - eglChooseConfig(display, configureAttributes.constData(), configs, size, &matching);
  63. - for (EGLint index = 0; index < size; ++index) {
  64. - EGLint red, green, blue, alpha;
  65. - eglGetConfigAttrib(display, configs[index], EGL_RED_SIZE, &red);
  66. - eglGetConfigAttrib(display, configs[index], EGL_GREEN_SIZE, &green);
  67. - eglGetConfigAttrib(display, configs[index], EGL_BLUE_SIZE, &blue);
  68. - eglGetConfigAttrib(display, configs[index], EGL_ALPHA_SIZE, &alpha);
  69. - if ((confAttrRed == 0 || red == confAttrRed) &&
  70. - (confAttrGreen == 0 || green == confAttrGreen) &&
  71. - (confAttrBlue == 0 || blue == confAttrBlue) &&
  72. - (confAttrAlpha == 0 || alpha == confAttrAlpha)) {
  73. - cfg = configs[index];
  74. - delete [] configs;
  75. - return cfg;
  76. - }
  77. - }
  78. - delete [] configs;
  79. - } while (q_reduceConfigAttributes(&configureAttributes));
  80. - qWarning("Cant find EGLConfig, returning null config");
  81. - return 0;
  82. + EGLint configCount = 0;
  83. + assert(eglGetConfigs(display, 0, 0, &configCount) == EGL_TRUE);
  84. + //qDebug("%d EGL configurations were found.", configCount);
  85. + EGLConfig* configs = new EGLConfig[configCount];
  86. + assert(eglGetConfigs(display, configs, configCount, &configCount) == EGL_TRUE);
  87. +
  88. + // List the configurations.
  89. + for (int i = 0; i < configCount; i++) {
  90. + EGLint redSize, blueSize, greenSize, alphaSize;
  91. + //assert(eglGetConfigAttrib(display, *(configs + i), EGL_RED_SIZE, &redSize) == EGL_TRUE);
  92. + //assert(eglGetConfigAttrib(display, *(configs + i), EGL_GREEN_SIZE, &greenSize) == EGL_TRUE);
  93. + //assert(eglGetConfigAttrib(display, *(configs + i), EGL_BLUE_SIZE, &blueSize) == EGL_TRUE);
  94. + //assert(eglGetConfigAttrib(display, *(configs + i), EGL_ALPHA_SIZE, &alphaSize) == EGL_TRUE);
  95. + //qDebug("Config %d: RGBA(%d, %d, %d, %d).", i, redSize, greenSize, blueSize, alphaSize);
  96. + }
  97. +
  98. + // Choose the first 32 bit configuration.
  99. + EGLConfig config;
  100. + int i = 0;
  101. + for (i = 0; i < configCount; i++) {
  102. + EGLint redSize, blueSize, greenSize, alphaSize;
  103. + assert(eglGetConfigAttrib(display, *(configs + i), EGL_RED_SIZE, &redSize) == EGL_TRUE);
  104. + assert(eglGetConfigAttrib(display, *(configs + i), EGL_GREEN_SIZE, &greenSize) == EGL_TRUE);
  105. + assert(eglGetConfigAttrib(display, *(configs + i), EGL_BLUE_SIZE, &blueSize) == EGL_TRUE);
  106. + assert(eglGetConfigAttrib(display, *(configs + i), EGL_ALPHA_SIZE, &alphaSize) == EGL_TRUE);
  107. + //qDebug("Config %d: RGBA(%d, %d, %d, %d).", i, redSize, greenSize, blueSize, alphaSize);
  108. + if (redSize == 8 && blueSize == 8 && greenSize == 8 && alphaSize == 8) {
  109. + config = *(configs + i);
  110. + break;
  111. + }
  112. + }
  113. + delete[] configs;
  114. + return config;
  115. }
  116.  
  117. QSurfaceFormat q_glFormatFromConfig(EGLDisplay display, const EGLConfig config, const QSurfaceFormat &referenceFormat)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement