qxlibeglintegration.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/platformsupport/eglconvenience/qxlibeglintegration.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the plugins of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include <QLoggingCategory>-
41#include "qxlibeglintegration_p.h"-
42-
43Q_LOGGING_CATEGORY(lcXlibEglDebug, "qt.egl.xlib.debug")
never executed: return category;
0
44-
45VisualID QXlibEglIntegration::getCompatibleVisualId(Display *display, EGLDisplay eglDisplay, EGLConfig config)-
46{-
47 VisualID visualId = 0;-
48 EGLint eglValue = 0;-
49-
50 EGLint configRedSize = 0;-
51 eglGetConfigAttrib(eglDisplay, config, EGL_RED_SIZE, &configRedSize);-
52-
53 EGLint configGreenSize = 0;-
54 eglGetConfigAttrib(eglDisplay, config, EGL_GREEN_SIZE, &configGreenSize);-
55-
56 EGLint configBlueSize = 0;-
57 eglGetConfigAttrib(eglDisplay, config, EGL_BLUE_SIZE, &configBlueSize);-
58-
59 EGLint configAlphaSize = 0;-
60 eglGetConfigAttrib(eglDisplay, config, EGL_ALPHA_SIZE, &configAlphaSize);-
61-
62 eglGetConfigAttrib(eglDisplay, config, EGL_CONFIG_ID, &eglValue);-
63 int configId = eglValue;-
64-
65 // See if EGL provided a valid VisualID:-
66 eglGetConfigAttrib(eglDisplay, config, EGL_NATIVE_VISUAL_ID, &eglValue);-
67 visualId = (VisualID)eglValue;-
68 if (visualId) {
visualIdDescription
TRUEnever evaluated
FALSEnever evaluated
0
69 // EGL has suggested a visual id, so get the rest of the visual info for that id:-
70 XVisualInfo visualInfoTemplate;-
71 memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));-
72 visualInfoTemplate.visualid = visualId;-
73-
74 XVisualInfo *chosenVisualInfo;-
75 int matchingCount = 0;-
76 chosenVisualInfo = XGetVisualInfo(display, VisualIDMask, &visualInfoTemplate, &matchingCount);-
77 if (chosenVisualInfo) {
chosenVisualInfoDescription
TRUEnever evaluated
FALSEnever evaluated
0
78 // Skip size checks if implementation supports non-matching visual-
79 // and config (QTBUG-9444).-
80 if (q_hasEglExtension(eglDisplay,"EGL_NV_post_convert_rounding")) {
q_hasEglExtens...ert_rounding")Description
TRUEnever evaluated
FALSEnever evaluated
0
81 XFree(chosenVisualInfo);-
82 return visualId;
never executed: return visualId;
0
83 }-
84 // Skip also for i.MX6 where 565 visuals are suggested for the default 444 configs and it works just fine.-
85 const char *vendor = eglQueryString(eglDisplay, EGL_VENDOR);-
86 if (vendor && strstr(vendor, "Vivante")) {
vendorDescription
TRUEnever evaluated
FALSEnever evaluated
strstr(vendor, "Vivante")Description
TRUEnever evaluated
FALSEnever evaluated
0
87 XFree(chosenVisualInfo);-
88 return visualId;
never executed: return visualId;
0
89 }-
90-
91 int visualRedSize = qPopulationCount(chosenVisualInfo->red_mask);-
92 int visualGreenSize = qPopulationCount(chosenVisualInfo->green_mask);-
93 int visualBlueSize = qPopulationCount(chosenVisualInfo->blue_mask);-
94 int visualAlphaSize = chosenVisualInfo->depth == 32 ? 8 : 0;
chosenVisualInfo->depth == 32Description
TRUEnever evaluated
FALSEnever evaluated
0
95-
96 const bool visualMatchesConfig = visualRedSize == configRedSize
visualRedSize == configRedSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
97 && visualGreenSize == configGreenSize
visualGreenSiz...onfigGreenSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
98 && visualBlueSize == configBlueSize
visualBlueSize...configBlueSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
99 && visualAlphaSize == configAlphaSize;
visualAlphaSiz...onfigAlphaSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
100-
101 // In some cases EGL tends to suggest a 24-bit visual for 8888-
102 // configs. In such a case we have to fall back to XGetVisualInfo.-
103 if (!visualMatchesConfig) {
!visualMatchesConfigDescription
TRUEnever evaluated
FALSEnever evaluated
0
104 visualId = 0;-
105 qCDebug(lcXlibEglDebug,
never executed: QMessageLogger( __FILE__ , 109 , __PRETTY_FUNCTION__, lcXlibEglDebug().categoryName()).debug("EGL suggested using X Visual ID %d (%d %d %d depth %d) for EGL config %d" "(%d %d %d %d), but this is incompatible", (int)visualId, visualRedSize, visualGreenSize, visualBlueSize, chosenVisualInfo->depth, configId, configRedSize, configGreenSize, configBlueSize, configAlphaSize) ;
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
106 "EGL suggested using X Visual ID %d (%d %d %d depth %d) for EGL config %d"
never executed: QMessageLogger( __FILE__ , 109 , __PRETTY_FUNCTION__, lcXlibEglDebug().categoryName()).debug("EGL suggested using X Visual ID %d (%d %d %d depth %d) for EGL config %d" "(%d %d %d %d), but this is incompatible", (int)visualId, visualRedSize, visualGreenSize, visualBlueSize, chosenVisualInfo->depth, configId, configRedSize, configGreenSize, configBlueSize, configAlphaSize) ;
0
107 "(%d %d %d %d), but this is incompatible",
never executed: QMessageLogger( __FILE__ , 109 , __PRETTY_FUNCTION__, lcXlibEglDebug().categoryName()).debug("EGL suggested using X Visual ID %d (%d %d %d depth %d) for EGL config %d" "(%d %d %d %d), but this is incompatible", (int)visualId, visualRedSize, visualGreenSize, visualBlueSize, chosenVisualInfo->depth, configId, configRedSize, configGreenSize, configBlueSize, configAlphaSize) ;
0
108 (int)visualId, visualRedSize, visualGreenSize, visualBlueSize, chosenVisualInfo->depth,
never executed: QMessageLogger( __FILE__ , 109 , __PRETTY_FUNCTION__, lcXlibEglDebug().categoryName()).debug("EGL suggested using X Visual ID %d (%d %d %d depth %d) for EGL config %d" "(%d %d %d %d), but this is incompatible", (int)visualId, visualRedSize, visualGreenSize, visualBlueSize, chosenVisualInfo->depth, configId, configRedSize, configGreenSize, configBlueSize, configAlphaSize) ;
0
109 configId, configRedSize, configGreenSize, configBlueSize, configAlphaSize);
never executed: QMessageLogger( __FILE__ , 109 , __PRETTY_FUNCTION__, lcXlibEglDebug().categoryName()).debug("EGL suggested using X Visual ID %d (%d %d %d depth %d) for EGL config %d" "(%d %d %d %d), but this is incompatible", (int)visualId, visualRedSize, visualGreenSize, visualBlueSize, chosenVisualInfo->depth, configId, configRedSize, configGreenSize, configBlueSize, configAlphaSize) ;
0
110 }
never executed: end of block
0
111 } else {
never executed: end of block
0
112 qCDebug(lcXlibEglDebug, "EGL suggested using X Visual ID %d for EGL config %d, but that isn't a valid ID",
never executed: QMessageLogger( __FILE__ , 113 , __PRETTY_FUNCTION__, lcXlibEglDebug().categoryName()).debug("EGL suggested using X Visual ID %d for EGL config %d, but that isn't a valid ID", (int)visualId, configId) ;
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
113 (int)visualId, configId);
never executed: QMessageLogger( __FILE__ , 113 , __PRETTY_FUNCTION__, lcXlibEglDebug().categoryName()).debug("EGL suggested using X Visual ID %d for EGL config %d, but that isn't a valid ID", (int)visualId, configId) ;
0
114 visualId = 0;-
115 }
never executed: end of block
0
116 XFree(chosenVisualInfo);-
117 }
never executed: end of block
0
118 else-
119 qCDebug(lcXlibEglDebug, "EGL did not suggest a VisualID (EGL_NATIVE_VISUAL_ID was zero) for EGLConfig %d", configId);
never executed: QMessageLogger(__FILE__, 119, __PRETTY_FUNCTION__, lcXlibEglDebug().categoryName()).debug("EGL did not suggest a VisualID (EGL_NATIVE_VISUAL_ID was zero) for EGLConfig %d", configId);
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
120-
121 if (visualId) {
visualIdDescription
TRUEnever evaluated
FALSEnever evaluated
0
122 qCDebug(lcXlibEglDebug, configAlphaSize > 0
never executed: QMessageLogger( __FILE__ , 124 , __PRETTY_FUNCTION__, lcXlibEglDebug().categoryName()).debug(configAlphaSize > 0 ? "Using ARGB Visual ID %d provided by EGL for config %d" : "Using Opaque Visual ID %d provided by EGL for config %d", (int)visualId, configId) ;
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
123 ? "Using ARGB Visual ID %d provided by EGL for config %d"
never executed: QMessageLogger( __FILE__ , 124 , __PRETTY_FUNCTION__, lcXlibEglDebug().categoryName()).debug(configAlphaSize > 0 ? "Using ARGB Visual ID %d provided by EGL for config %d" : "Using Opaque Visual ID %d provided by EGL for config %d", (int)visualId, configId) ;
0
124 : "Using Opaque Visual ID %d provided by EGL for config %d", (int)visualId, configId);
never executed: QMessageLogger( __FILE__ , 124 , __PRETTY_FUNCTION__, lcXlibEglDebug().categoryName()).debug(configAlphaSize > 0 ? "Using ARGB Visual ID %d provided by EGL for config %d" : "Using Opaque Visual ID %d provided by EGL for config %d", (int)visualId, configId) ;
0
125 return visualId;
never executed: return visualId;
0
126 }-
127-
128 // Finally, try to use XGetVisualInfo and only use the bit depths to match on:-
129 if (!visualId) {
!visualIdDescription
TRUEnever evaluated
FALSEnever evaluated
0
130 XVisualInfo visualInfoTemplate;-
131 memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));-
132 XVisualInfo *matchingVisuals;-
133 int matchingCount = 0;-
134-
135 visualInfoTemplate.depth = configRedSize + configGreenSize + configBlueSize + configAlphaSize;-
136 matchingVisuals = XGetVisualInfo(display,-
137 VisualDepthMask,-
138 &visualInfoTemplate,-
139 &matchingCount);-
140 if (!matchingVisuals) {
!matchingVisualsDescription
TRUEnever evaluated
FALSEnever evaluated
0
141 // Try again without taking the alpha channel into account:-
142 visualInfoTemplate.depth = configRedSize + configGreenSize + configBlueSize;-
143 matchingVisuals = XGetVisualInfo(display,-
144 VisualDepthMask,-
145 &visualInfoTemplate,-
146 &matchingCount);-
147 }
never executed: end of block
0
148-
149 if (matchingVisuals) {
matchingVisualsDescription
TRUEnever evaluated
FALSEnever evaluated
0
150 visualId = matchingVisuals[0].visualid;-
151 XFree(matchingVisuals);-
152 }
never executed: end of block
0
153 }
never executed: end of block
0
154-
155 if (visualId) {
visualIdDescription
TRUEnever evaluated
FALSEnever evaluated
0
156 qCDebug(lcXlibEglDebug, "Using Visual ID %d provided by XGetVisualInfo for EGL config %d", (int)visualId, configId);
never executed: QMessageLogger(__FILE__, 156, __PRETTY_FUNCTION__, lcXlibEglDebug().categoryName()).debug("Using Visual ID %d provided by XGetVisualInfo for EGL config %d", (int)visualId, configId);
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
157 return visualId;
never executed: return visualId;
0
158 }-
159-
160 qWarning("Unable to find an X11 visual which matches EGL config %d", configId);-
161 return (VisualID)0;
never executed: return (VisualID)0;
0
162}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9