Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/opengl/qglfunctions.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | - | |||||||
2 | - | |||||||
3 | struct QGLFunctionsPrivateEx : public QGLFunctionsPrivate, public QOpenGLSharedResource | - | ||||||
4 | { | - | ||||||
5 | QGLFunctionsPrivateEx(QOpenGLContext *context) | - | ||||||
6 | : QGLFunctionsPrivate(QGLContext::fromOpenGLContext(context)) | - | ||||||
7 | , QOpenGLSharedResource(context->shareGroup()) | - | ||||||
8 | , m_features(-1) | - | ||||||
9 | { | - | ||||||
10 | funcs = new QOpenGLFunctions(context); | - | ||||||
11 | funcs->initializeOpenGLFunctions(); | - | ||||||
12 | } executed 2 times by 2 tests: end of block Executed by:
| 2 | ||||||
13 | - | |||||||
14 | ~QGLFunctionsPrivateEx() | - | ||||||
15 | { | - | ||||||
16 | delete funcs; | - | ||||||
17 | } executed 2 times by 2 tests: end of block Executed by:
| 2 | ||||||
18 | - | |||||||
19 | void invalidateResource() override | - | ||||||
20 | { | - | ||||||
21 | m_features = -1; | - | ||||||
22 | } executed 2 times by 2 tests: end of block Executed by:
| 2 | ||||||
23 | - | |||||||
24 | void freeResource(QOpenGLContext *) override | - | ||||||
25 | { | - | ||||||
26 | - | |||||||
27 | } | - | ||||||
28 | - | |||||||
29 | int m_features; | - | ||||||
30 | }; | - | ||||||
31 | - | |||||||
32 | namespace { namespace Q_QGS_qt_gl_functions_resource { typedef QOpenGLMultiGroupSharedResource Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized
executed 2 times by 2 tests: }guard.store(QtGlobalStatic::Destroyed); Executed by:
executed 2 times by 2 tests: }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; returnend of block Executed by:
executed 3 times by 2 tests: &holder.value;return &holder.value; Executed by:
executed 3 times by 2 tests: } } } static QGlobalStatic<QOpenGLMultiGroupSharedResource, Q_QGS_qt_gl_functions_resource::innerFunction, Q_QGS_qt_gl_functions_resource::guard> qt_gl_functions_resource;return &holder.value; Executed by:
| 0-3 | ||||||
33 | - | |||||||
34 | static QGLFunctionsPrivateEx *qt_gl_functions(const QGLContext *context = 0) | - | ||||||
35 | { | - | ||||||
36 | if (!context
| 1-2 | ||||||
37 | context = QGLContext::currentContext(); executed 1 time by 1 test: context = QGLContext::currentContext(); Executed by:
| 1 | ||||||
38 | ((!(context)) ? qt_assert("context",__FILE__,181) : qt_noop()); | - | ||||||
39 | QGLFunctionsPrivateEx *funcs = | - | ||||||
40 | reinterpret_cast<QGLFunctionsPrivateEx *> | - | ||||||
41 | (qt_gl_functions_resource()->value<QGLFunctionsPrivateEx>(context->contextHandle())); | - | ||||||
42 | return executed 3 times by 2 tests: funcs;return funcs; Executed by:
executed 3 times by 2 tests: return funcs; Executed by:
| 3 | ||||||
43 | } | - | ||||||
44 | QGLFunctions::QGLFunctions() | - | ||||||
45 | : d_ptr(0) | - | ||||||
46 | { | - | ||||||
47 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||
48 | QGLFunctions::QGLFunctions(const QGLContext *context) | - | ||||||
49 | : d_ptr(qt_gl_functions(context)) | - | ||||||
50 | { | - | ||||||
51 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||
52 | - | |||||||
53 | - | |||||||
54 | - | |||||||
55 | - | |||||||
56 | - | |||||||
57 | - | |||||||
58 | - | |||||||
59 | static int qt_gl_resolve_features() | - | ||||||
60 | { | - | ||||||
61 | QOpenGLContext *ctx = QOpenGLContext::currentContext(); | - | ||||||
62 | if (ctx->isOpenGLES()
| 0-1 | ||||||
63 | - | |||||||
64 | int features = QGLFunctions::Multitexture | | - | ||||||
65 | QGLFunctions::Shaders | | - | ||||||
66 | QGLFunctions::Buffers | | - | ||||||
67 | QGLFunctions::Framebuffers | | - | ||||||
68 | QGLFunctions::BlendColor | | - | ||||||
69 | QGLFunctions::BlendEquation | | - | ||||||
70 | QGLFunctions::BlendEquationSeparate | | - | ||||||
71 | QGLFunctions::BlendFuncSeparate | | - | ||||||
72 | QGLFunctions::BlendSubtract | | - | ||||||
73 | QGLFunctions::CompressedTextures | | - | ||||||
74 | QGLFunctions::Multisample | | - | ||||||
75 | QGLFunctions::StencilSeparate; | - | ||||||
76 | QOpenGLExtensionMatcher extensions; | - | ||||||
77 | if (extensions.match("GL_OES_texture_npot")
| 0 | ||||||
78 | features |= QGLFunctions::NPOTTextures; never executed: features |= QGLFunctions::NPOTTextures; | 0 | ||||||
79 | if (extensions.match("GL_IMG_texture_npot")
| 0 | ||||||
80 | features |= QGLFunctions::NPOTTextures; never executed: features |= QGLFunctions::NPOTTextures; | 0 | ||||||
81 | return never executed: features;return features; never executed: return features; | 0 | ||||||
82 | } else { | - | ||||||
83 | - | |||||||
84 | int features = 0; | - | ||||||
85 | QGLFormat::OpenGLVersionFlags versions = QGLFormat::openGLVersionFlags(); | - | ||||||
86 | QOpenGLExtensionMatcher extensions; | - | ||||||
87 | - | |||||||
88 | - | |||||||
89 | if (extensions.match("GL_ARB_multitexture")
| 0-1 | ||||||
90 | features |= QGLFunctions::Multitexture; executed 1 time by 1 test: features |= QGLFunctions::Multitexture; Executed by:
| 1 | ||||||
91 | if (extensions.match("GL_ARB_shader_objects")
| 0-1 | ||||||
92 | features |= QGLFunctions::Shaders; executed 1 time by 1 test: features |= QGLFunctions::Shaders; Executed by:
| 1 | ||||||
93 | if (extensions.match("GL_EXT_framebuffer_object")
| 0-1 | ||||||
94 | extensions.match("GL_ARB_framebuffer_object")
| 0 | ||||||
95 | features |= QGLFunctions::Framebuffers; executed 1 time by 1 test: features |= QGLFunctions::Framebuffers; Executed by:
| 1 | ||||||
96 | if (extensions.match("GL_EXT_blend_color")
| 0-1 | ||||||
97 | features |= QGLFunctions::BlendColor; executed 1 time by 1 test: features |= QGLFunctions::BlendColor; Executed by:
| 1 | ||||||
98 | if (extensions.match("GL_EXT_blend_equation_separate")
| 0-1 | ||||||
99 | features |= QGLFunctions::BlendEquationSeparate; executed 1 time by 1 test: features |= QGLFunctions::BlendEquationSeparate; Executed by:
| 1 | ||||||
100 | if (extensions.match("GL_EXT_blend_func_separate")
| 0-1 | ||||||
101 | features |= QGLFunctions::BlendFuncSeparate; executed 1 time by 1 test: features |= QGLFunctions::BlendFuncSeparate; Executed by:
| 1 | ||||||
102 | if (extensions.match("GL_EXT_blend_subtract")
| 0-1 | ||||||
103 | features |= QGLFunctions::BlendSubtract; executed 1 time by 1 test: features |= QGLFunctions::BlendSubtract; Executed by:
| 1 | ||||||
104 | if (extensions.match("GL_ARB_texture_compression")
| 0-1 | ||||||
105 | features |= QGLFunctions::CompressedTextures; executed 1 time by 1 test: features |= QGLFunctions::CompressedTextures; Executed by:
| 1 | ||||||
106 | if (extensions.match("GL_ARB_multisample")
| 0-1 | ||||||
107 | features |= QGLFunctions::Multisample; executed 1 time by 1 test: features |= QGLFunctions::Multisample; Executed by:
| 1 | ||||||
108 | if (extensions.match("GL_ARB_texture_non_power_of_two")
| 0-1 | ||||||
109 | features |= QGLFunctions::NPOTTextures; executed 1 time by 1 test: features |= QGLFunctions::NPOTTextures; Executed by:
| 1 | ||||||
110 | - | |||||||
111 | - | |||||||
112 | if (versions & QGLFormat::OpenGL_Version_1_2
| 0-1 | ||||||
113 | features |= QGLFunctions::BlendColor | | - | ||||||
114 | QGLFunctions::BlendEquation; | - | ||||||
115 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||
116 | if (versions & QGLFormat::OpenGL_Version_1_3
| 0-1 | ||||||
117 | features |= QGLFunctions::Multitexture | | - | ||||||
118 | QGLFunctions::CompressedTextures | | - | ||||||
119 | QGLFunctions::Multisample; | - | ||||||
120 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||
121 | if (versions & QGLFormat::OpenGL_Version_1_4
| 0-1 | ||||||
122 | features |= QGLFunctions::BlendFuncSeparate; executed 1 time by 1 test: features |= QGLFunctions::BlendFuncSeparate; Executed by:
| 1 | ||||||
123 | if (versions & QGLFormat::OpenGL_Version_1_5
| 0-1 | ||||||
124 | features |= QGLFunctions::Buffers; executed 1 time by 1 test: features |= QGLFunctions::Buffers; Executed by:
| 1 | ||||||
125 | if (versions & QGLFormat::OpenGL_Version_2_0
| 0-1 | ||||||
126 | features |= QGLFunctions::Shaders | | - | ||||||
127 | QGLFunctions::StencilSeparate | | - | ||||||
128 | QGLFunctions::BlendEquationSeparate | | - | ||||||
129 | QGLFunctions::NPOTTextures; | - | ||||||
130 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||
131 | return executed 1 time by 1 test: features;return features; Executed by:
executed 1 time by 1 test: return features; Executed by:
| 1 | ||||||
132 | } | - | ||||||
133 | } | - | ||||||
134 | QGLFunctions::OpenGLFeatures QGLFunctions::openGLFeatures() const | - | ||||||
135 | { | - | ||||||
136 | QGLFunctionsPrivateEx *d = static_cast<QGLFunctionsPrivateEx *>(d_ptr); | - | ||||||
137 | if (!d
| 0-1 | ||||||
138 | return executed 1 time by 1 test: 0;return 0; Executed by:
executed 1 time by 1 test: return 0; Executed by:
| 1 | ||||||
139 | if (d->m_features == -1
| 0 | ||||||
140 | d->m_features = qt_gl_resolve_features(); never executed: d->m_features = qt_gl_resolve_features(); | 0 | ||||||
141 | return never executed: QGLFunctions::OpenGLFeatures(d->m_features);return QGLFunctions::OpenGLFeatures(d->m_features); never executed: return QGLFunctions::OpenGLFeatures(d->m_features); | 0 | ||||||
142 | } | - | ||||||
143 | bool QGLFunctions::hasOpenGLFeature(QGLFunctions::OpenGLFeature feature) const | - | ||||||
144 | { | - | ||||||
145 | QGLFunctionsPrivateEx *d = static_cast<QGLFunctionsPrivateEx *>(d_ptr); | - | ||||||
146 | if (!d
| 13 | ||||||
147 | return executed 13 times by 1 test: false;return false; Executed by:
executed 13 times by 1 test: return false; Executed by:
| 13 | ||||||
148 | if (d->m_features == -1
| 1-12 | ||||||
149 | d->m_features = qt_gl_resolve_features(); executed 1 time by 1 test: d->m_features = qt_gl_resolve_features(); Executed by:
| 1 | ||||||
150 | return executed 13 times by 1 test: (d->m_features & int(feature)) != 0;return (d->m_features & int(feature)) != 0; Executed by:
executed 13 times by 1 test: return (d->m_features & int(feature)) != 0; Executed by:
| 13 | ||||||
151 | } | - | ||||||
152 | void QGLFunctions::initializeGLFunctions(const QGLContext *context) | - | ||||||
153 | { | - | ||||||
154 | d_ptr = qt_gl_functions(context); | - | ||||||
155 | } executed 2 times by 2 tests: end of block Executed by:
| 2 | ||||||
156 | QGLFunctionsPrivate::QGLFunctionsPrivate(const QGLContext *) | - | ||||||
157 | : funcs(0) | - | ||||||
158 | { | - | ||||||
159 | } executed 2 times by 2 tests: end of block Executed by:
| 2 | ||||||
160 | - | |||||||
161 | - | |||||||
Switch to Source code | Preprocessed file |