| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickopenglinfo.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||
| 2 | ** | - | ||||||
| 3 | ** Copyright (C) 2016 BlackBerry Ltd. | - | ||||||
| 4 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||
| 5 | ** Contact: https://www.qt.io/licensing/ | - | ||||||
| 6 | ** | - | ||||||
| 7 | ** This file is part of the QtQuick module of the Qt Toolkit. | - | ||||||
| 8 | ** | - | ||||||
| 9 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||
| 10 | ** Commercial License Usage | - | ||||||
| 11 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||
| 12 | ** accordance with the commercial license agreement provided with the | - | ||||||
| 13 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||
| 14 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||
| 15 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||
| 16 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||
| 17 | ** | - | ||||||
| 18 | ** GNU Lesser General Public License Usage | - | ||||||
| 19 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||
| 20 | ** General Public License version 3 as published by the Free Software | - | ||||||
| 21 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||
| 22 | ** packaging of this file. Please review the following information to | - | ||||||
| 23 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||
| 24 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||
| 25 | ** | - | ||||||
| 26 | ** GNU General Public License Usage | - | ||||||
| 27 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||
| 28 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||
| 29 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||
| 30 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||
| 31 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||
| 32 | ** included in the packaging of this file. Please review the following | - | ||||||
| 33 | ** information to ensure the GNU General Public License requirements will | - | ||||||
| 34 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||
| 35 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||
| 36 | ** | - | ||||||
| 37 | ** $QT_END_LICENSE$ | - | ||||||
| 38 | ** | - | ||||||
| 39 | ****************************************************************************/ | - | ||||||
| 40 | - | |||||||
| 41 | #include "qquickopenglinfo_p.h" | - | ||||||
| 42 | #include "qopenglcontext.h" | - | ||||||
| 43 | #include "qquickwindow.h" | - | ||||||
| 44 | #include "qquickitem.h" | - | ||||||
| 45 | - | |||||||
| 46 | QT_BEGIN_NAMESPACE | - | ||||||
| 47 | - | |||||||
| 48 | /*! | - | ||||||
| 49 | \qmltype OpenGLInfo | - | ||||||
| 50 | \instantiates QQuickOpenGLInfo | - | ||||||
| 51 | \inqmlmodule QtQuick | - | ||||||
| 52 | \ingroup qtquick-effects | - | ||||||
| 53 | \since 5.4 | - | ||||||
| 54 | \brief Provides information about the used OpenGL version. | - | ||||||
| 55 | - | |||||||
| 56 | The OpenGLInfo attached type provides information about the OpenGL | - | ||||||
| 57 | version being used to render the surface of the attachee item. | - | ||||||
| 58 | - | |||||||
| 59 | If the attachee item is not currently associated with any graphical | - | ||||||
| 60 | surface, the properties are set to the values of the default surface | - | ||||||
| 61 | format. When it becomes associated with a surface, all properties | - | ||||||
| 62 | will update. | - | ||||||
| 63 | - | |||||||
| 64 | \deprecated | - | ||||||
| 65 | - | |||||||
| 66 | \warning This type is deprecated. Use GraphicsInfo instead. | - | ||||||
| 67 | - | |||||||
| 68 | \sa ShaderEffect | - | ||||||
| 69 | */ | - | ||||||
| 70 | QQuickOpenGLInfo::QQuickOpenGLInfo(QQuickItem *item) | - | ||||||
| 71 | : QObject(item) | - | ||||||
| 72 | , m_window(nullptr) | - | ||||||
| 73 | , m_majorVersion(2) | - | ||||||
| 74 | , m_minorVersion(0) | - | ||||||
| 75 | , m_profile(NoProfile) | - | ||||||
| 76 | , m_renderableType(Unspecified) | - | ||||||
| 77 | { | - | ||||||
| 78 | connect(item, SIGNAL(windowChanged(QQuickWindow*)), this, SLOT(setWindow(QQuickWindow*))); | - | ||||||
| 79 | setWindow(item->window()); | - | ||||||
| 80 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||
| 81 | - | |||||||
| 82 | /*! | - | ||||||
| 83 | \qmlproperty int QtQuick::OpenGLInfo::majorVersion | - | ||||||
| 84 | - | |||||||
| 85 | This property holds the major OpenGL version. | - | ||||||
| 86 | - | |||||||
| 87 | The default version is \c 2.0. | - | ||||||
| 88 | - | |||||||
| 89 | \sa minorVersion, profile | - | ||||||
| 90 | */ | - | ||||||
| 91 | int QQuickOpenGLInfo::majorVersion() const | - | ||||||
| 92 | { | - | ||||||
| 93 | return m_majorVersion; executed 2 times by 1 test: return m_majorVersion;Executed by:
| 2 | ||||||
| 94 | } | - | ||||||
| 95 | - | |||||||
| 96 | /*! | - | ||||||
| 97 | \qmlproperty int QtQuick::OpenGLInfo::minorVersion | - | ||||||
| 98 | - | |||||||
| 99 | This property holds the minor OpenGL version. | - | ||||||
| 100 | - | |||||||
| 101 | The default version is \c 2.0. | - | ||||||
| 102 | - | |||||||
| 103 | \sa majorVersion, profile | - | ||||||
| 104 | */ | - | ||||||
| 105 | int QQuickOpenGLInfo::minorVersion() const | - | ||||||
| 106 | { | - | ||||||
| 107 | return m_minorVersion; executed 2 times by 1 test: return m_minorVersion;Executed by:
| 2 | ||||||
| 108 | } | - | ||||||
| 109 | - | |||||||
| 110 | /*! | - | ||||||
| 111 | \qmlproperty enumeration QtQuick::OpenGLInfo::profile | - | ||||||
| 112 | - | |||||||
| 113 | This property holds the configured OpenGL context profile. | - | ||||||
| 114 | - | |||||||
| 115 | The possible values are: | - | ||||||
| 116 | \list | - | ||||||
| 117 | \li OpenGLInfo.NoProfile (default) - OpenGL version is lower than 3.2. | - | ||||||
| 118 | \li OpenGLInfo.CoreProfile - Functionality deprecated in OpenGL version 3.0 is not available. | - | ||||||
| 119 | \li OpenGLInfo.CompatibilityProfile - Functionality from earlier OpenGL versions is available. | - | ||||||
| 120 | \endlist | - | ||||||
| 121 | - | |||||||
| 122 | Reusable QML components will typically use this property in bindings in order to | - | ||||||
| 123 | choose between core and non core profile compatible shader sources. | - | ||||||
| 124 | - | |||||||
| 125 | \sa majorVersion, minorVersion | - | ||||||
| 126 | */ | - | ||||||
| 127 | QQuickOpenGLInfo::ContextProfile QQuickOpenGLInfo::profile() const | - | ||||||
| 128 | { | - | ||||||
| 129 | return m_profile; executed 2 times by 1 test: return m_profile;Executed by:
| 2 | ||||||
| 130 | } | - | ||||||
| 131 | - | |||||||
| 132 | /*! | - | ||||||
| 133 | \qmlproperty enumeration QtQuick::OpenGLInfo::renderableType | - | ||||||
| 134 | - | |||||||
| 135 | This property holds the renderable type. | - | ||||||
| 136 | - | |||||||
| 137 | The possible values are: | - | ||||||
| 138 | \list | - | ||||||
| 139 | \li OpenGLInfo.Unspecified (default) - Unspecified rendering method | - | ||||||
| 140 | \li OpenGLInfo.OpenGL - Desktop OpenGL rendering | - | ||||||
| 141 | \li OpenGLInfo.OpenGLES - OpenGL ES rendering | - | ||||||
| 142 | \endlist | - | ||||||
| 143 | */ | - | ||||||
| 144 | QQuickOpenGLInfo::RenderableType QQuickOpenGLInfo::renderableType() const | - | ||||||
| 145 | { | - | ||||||
| 146 | return m_renderableType; executed 2 times by 1 test: return m_renderableType;Executed by:
| 2 | ||||||
| 147 | } | - | ||||||
| 148 | - | |||||||
| 149 | QQuickOpenGLInfo *QQuickOpenGLInfo::qmlAttachedProperties(QObject *object) | - | ||||||
| 150 | { | - | ||||||
| 151 | if (QQuickItem *item = qobject_cast<QQuickItem *>(object))
| 0-2 | ||||||
| 152 | return new QQuickOpenGLInfo(item); executed 2 times by 1 test: return new QQuickOpenGLInfo(item);Executed by:
| 2 | ||||||
| 153 | return nullptr; never executed: return nullptr; | 0 | ||||||
| 154 | } | - | ||||||
| 155 | - | |||||||
| 156 | void QQuickOpenGLInfo::updateFormat() | - | ||||||
| 157 | { | - | ||||||
| 158 | QOpenGLContext *context = nullptr; | - | ||||||
| 159 | if (m_window)
| 2-4 | ||||||
| 160 | context = m_window->openglContext(); executed 2 times by 1 test: context = m_window->openglContext();Executed by:
| 2 | ||||||
| 161 | QSurfaceFormat format = context ? context->format() : QSurfaceFormat::defaultFormat();
| 0-6 | ||||||
| 162 | - | |||||||
| 163 | if (m_majorVersion != format.majorVersion()) {
| 0-6 | ||||||
| 164 | m_majorVersion = format.majorVersion(); | - | ||||||
| 165 | emit majorVersionChanged(); | - | ||||||
| 166 | } never executed: end of block | 0 | ||||||
| 167 | - | |||||||
| 168 | if (m_minorVersion != format.minorVersion()) {
| 0-6 | ||||||
| 169 | m_minorVersion = format.minorVersion(); | - | ||||||
| 170 | emit minorVersionChanged(); | - | ||||||
| 171 | } never executed: end of block | 0 | ||||||
| 172 | - | |||||||
| 173 | ContextProfile profile = static_cast<ContextProfile>(format.profile()); | - | ||||||
| 174 | if (m_profile != profile) {
| 0-6 | ||||||
| 175 | m_profile = profile; | - | ||||||
| 176 | emit profileChanged(); | - | ||||||
| 177 | } never executed: end of block | 0 | ||||||
| 178 | - | |||||||
| 179 | RenderableType renderableType = static_cast<RenderableType>(format.renderableType()); | - | ||||||
| 180 | if (m_renderableType != renderableType) {
| 0-6 | ||||||
| 181 | m_renderableType = renderableType; | - | ||||||
| 182 | emit renderableTypeChanged(); | - | ||||||
| 183 | } never executed: end of block | 0 | ||||||
| 184 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||
| 185 | - | |||||||
| 186 | void QQuickOpenGLInfo::setWindow(QQuickWindow *window) | - | ||||||
| 187 | { | - | ||||||
| 188 | if (m_window != window) {
| 2-4 | ||||||
| 189 | if (m_window) {
| 2 | ||||||
| 190 | disconnect(m_window, SIGNAL(sceneGraphInitialized()), this, SLOT(updateFormat())); | - | ||||||
| 191 | disconnect(m_window, SIGNAL(sceneGraphInvalidated()), this, SLOT(updateFormat())); | - | ||||||
| 192 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||
| 193 | if (window) {
| 2 | ||||||
| 194 | connect(window, SIGNAL(sceneGraphInitialized()), this, SLOT(updateFormat())); | - | ||||||
| 195 | connect(window, SIGNAL(sceneGraphInvalidated()), this, SLOT(updateFormat())); | - | ||||||
| 196 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||
| 197 | m_window = window; | - | ||||||
| 198 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||
| 199 | updateFormat(); | - | ||||||
| 200 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||
| 201 | - | |||||||
| 202 | QT_END_NAMESPACE | - | ||||||
| 203 | - | |||||||
| 204 | #include "moc_qquickopenglinfo_p.cpp" | - | ||||||
| Source code | Switch to Preprocessed file |