aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items
diff options
context:
space:
mode:
Diffstat (limited to 'src/quick/items')
-rw-r--r--src/quick/items/items.pri4
-rw-r--r--src/quick/items/qquickgenericshadereffect.cpp30
-rw-r--r--src/quick/items/qquickgenericshadereffect_p.h4
-rw-r--r--src/quick/items/qquickgraphicsinfo.cpp306
-rw-r--r--src/quick/items/qquickgraphicsinfo_p.h166
-rw-r--r--src/quick/items/qquickitemsmodule.cpp5
-rw-r--r--src/quick/items/qquickopenglinfo.cpp4
-rw-r--r--src/quick/items/qquickrendererinfo.cpp129
-rw-r--r--src/quick/items/qquickrendererinfo_p.h100
-rw-r--r--src/quick/items/qquickshadereffect.cpp122
-rw-r--r--src/quick/items/qquickshadereffect_p.h30
11 files changed, 485 insertions, 415 deletions
diff --git a/src/quick/items/items.pri b/src/quick/items/items.pri
index eee11e9d75..0c7dc97a2c 100644
--- a/src/quick/items/items.pri
+++ b/src/quick/items/items.pri
@@ -78,7 +78,7 @@ HEADERS += \
$$PWD/qquickgenericshadereffect_p.h \
$$PWD/qquickrendercontrol.h \
$$PWD/qquickrendercontrol_p.h \
- $$PWD/qquickrendererinfo_p.h \
+ $$PWD/qquickgraphicsinfo_p.h \
$$PWD/qquickitemgrabresult.h
SOURCES += \
@@ -133,7 +133,7 @@ SOURCES += \
$$PWD/qquickshadereffect.cpp \
$$PWD/qquickgenericshadereffect.cpp \
$$PWD/qquickrendercontrol.cpp \
- $$PWD/qquickrendererinfo.cpp \
+ $$PWD/qquickgraphicsinfo.cpp \
$$PWD/qquickitemgrabresult.cpp
# Items that depend on OpenGL Renderer
diff --git a/src/quick/items/qquickgenericshadereffect.cpp b/src/quick/items/qquickgenericshadereffect.cpp
index cad3520ed1..47272a2eac 100644
--- a/src/quick/items/qquickgenericshadereffect.cpp
+++ b/src/quick/items/qquickgenericshadereffect.cpp
@@ -202,33 +202,6 @@ QQuickShaderEffect::Status QQuickGenericShaderEffect::status() const
return QQuickShaderEffect::Status(mgr->status());
}
-QQuickShaderEffect::ShaderType QQuickGenericShaderEffect::shaderType() const
-{
- QSGGuiThreadShaderEffectManager *mgr = shaderEffectManager();
- if (!mgr)
- return QQuickShaderEffect::ShaderType(0);
-
- return QQuickShaderEffect::ShaderType(mgr->shaderType());
-}
-
-QQuickShaderEffect::ShaderCompilationType QQuickGenericShaderEffect::shaderCompilationType() const
-{
- QSGGuiThreadShaderEffectManager *mgr = shaderEffectManager();
- if (!mgr)
- return QQuickShaderEffect::ShaderCompilationType(0);
-
- return QQuickShaderEffect::ShaderCompilationType(mgr->shaderCompilationType());
-}
-
-QQuickShaderEffect::ShaderSourceType QQuickGenericShaderEffect::shaderSourceType() const
-{
- QSGGuiThreadShaderEffectManager *mgr = shaderEffectManager();
- if (!mgr)
- return QQuickShaderEffect::ShaderSourceType(0);
-
- return QQuickShaderEffect::ShaderSourceType(mgr->shaderSourceType());
-}
-
void QQuickGenericShaderEffect::handleEvent(QEvent *event)
{
if (event->type() == QEvent::DynamicPropertyChange) {
@@ -381,9 +354,6 @@ void QQuickGenericShaderEffect::backendChanged()
disconnect(m_item->window(), SIGNAL(sceneGraphInitialized()), this, SLOT(backendChanged()));
emit m_item->logChanged();
emit m_item->statusChanged();
- emit m_item->shaderTypeChanged();
- emit m_item->shaderCompilationTypeChanged();
- emit m_item->shaderSourceTypeChanged();
}
void QQuickGenericShaderEffect::disconnectSignals(Shader shaderType)
diff --git a/src/quick/items/qquickgenericshadereffect_p.h b/src/quick/items/qquickgenericshadereffect_p.h
index 2af7d1156a..ab17a7fb87 100644
--- a/src/quick/items/qquickgenericshadereffect_p.h
+++ b/src/quick/items/qquickgenericshadereffect_p.h
@@ -90,10 +90,6 @@ public:
bool supportsAtlasTextures() const { return m_supportsAtlasTextures; }
void setSupportsAtlasTextures(bool supports);
- QQuickShaderEffect::ShaderType shaderType() const;
- QQuickShaderEffect::ShaderCompilationType shaderCompilationType() const;
- QQuickShaderEffect::ShaderSourceType shaderSourceType() const;
-
void handleEvent(QEvent *);
void handleGeometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
QSGNode *handleUpdatePaintNode(QSGNode *, QQuickItem::UpdatePaintNodeData *);
diff --git a/src/quick/items/qquickgraphicsinfo.cpp b/src/quick/items/qquickgraphicsinfo.cpp
new file mode 100644
index 0000000000..2dbad82acf
--- /dev/null
+++ b/src/quick/items/qquickgraphicsinfo.cpp
@@ -0,0 +1,306 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickgraphicsinfo_p.h"
+#include "qquickwindow.h"
+#include "qquickitem.h"
+#include <QtGui/qopenglcontext.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmltype GraphicsInfo
+ \instantiates QQuickGraphicsInfo
+ \inqmlmodule QtQuick
+ \ingroup qtquick-visual
+ \since 5.8
+ \since QtQuick 2.8
+ \brief Provides information about the used Qt Quick backend
+
+ The GraphicsInfo attached type provides information about the scenegraph
+ backend used to render the contents of the associated window.
+
+ If the item to which the properties are attached is not currently
+ associated with any window, the properties are set to default values. When
+ the associated window changes, the properties will update.
+ */
+
+QQuickGraphicsInfo::QQuickGraphicsInfo(QQuickItem *item)
+ : QObject(item)
+ , m_window(0)
+ , m_api(Unknown)
+ , m_shaderType(UnknownShadingLanguage)
+ , m_shaderCompilationType(ShaderCompilationType(0))
+ , m_shaderSourceType(ShaderSourceType(0))
+ , m_majorVersion(2)
+ , m_minorVersion(0)
+ , m_profile(NoProfile)
+ , m_renderableType(SurfaceFormatUnspecified)
+{
+ connect(item, SIGNAL(windowChanged(QQuickWindow*)), this, SLOT(setWindow(QQuickWindow*)));
+ setWindow(item->window());
+}
+
+QQuickGraphicsInfo *QQuickGraphicsInfo::qmlAttachedProperties(QObject *object)
+{
+ if (QQuickItem *item = qobject_cast<QQuickItem *>(object))
+ return new QQuickGraphicsInfo(item);
+
+ return nullptr;
+}
+
+/*!
+ \qmlproperty enumeration QtQuick::GraphicsInfo::api
+
+ This property describes the graphics API that is currently in use.
+
+ The possible values are:
+ \list
+ \li GraphicsInfo.Unknown - the default value when no active scenegraph is associated with the item
+ \li GraphicsInfo.Software - Qt Quick's software renderer based on QPainter with the raster paint engine
+ \li GraphicsInfo.OpenGL - OpenGL or OpenGL ES
+ \li GraphicsInfo.Direct3D12 - Direct3D 12
+ \endlist
+ */
+
+/*!
+ \qmlproperty enumeration QtQuick::GraphicsInfo::shaderType
+
+ This property contains the shading language supported by the Qt Quick
+ backend the application is using.
+
+ \list
+ \li GraphicsInfo.UnknownShadingLanguage - Not yet known due to no window and scenegraph associated
+ \li GraphicsInfo.GLSL - GLSL or GLSL ES
+ \li GraphicsInfo.HLSL - HLSL
+ \endlist
+
+ \note The value is only up-to-date once the item is associated with a
+ window and the window's scenegraph has initialized. Bindings relying on the
+ value have to keep this in mind since the value may change from
+ GraphicsInfo.UnknownShadingLanguage to the actual value after component
+ initialization is complete. This is particularly relevant for ShaderEffect
+ items inside ShaderEffectSource items set as property values.
+
+ \since 5.8
+ \since QtQuick 2.8
+
+ \sa shaderCompilationType, shaderSourceType
+*/
+
+/*!
+ \qmlproperty enumeration QtQuick::GraphicsInfo::shaderCompilationType
+
+ This property contains a bitmask of the shader compilation approaches
+ supported by the Qt Quick backend the application is using.
+
+ \list
+ \li GraphicsInfo.RuntimeCompilation
+ \li GraphicsInfo.OfflineCompilation
+ \endlist
+
+ With OpenGL the value is GraphicsInfo.RuntimeCompilation, which corresponds
+ to the traditional way of using ShaderEffect. Non-OpenGL backends are
+ expected to focus more on GraphicsInfo.OfflineCompilation, however.
+
+ \note The value is only up-to-date once the item is associated with a
+ window and the window's scenegraph has initialized. Bindings relying on the
+ value have to keep this in mind since the value may change from \c 0 to the
+ actual bitmask after component initialization is complete. This is
+ particularly relevant for ShaderEffect items inside ShaderEffectSource
+ items set as property values.
+
+ \since 5.8
+ \since QtQuick 2.8
+
+ \sa shaderType, shaderSourceType
+*/
+
+/*!
+ \qmlproperty enumeration QtQuick::GraphicsInfo::shaderSourceType
+
+ This property contains a bitmask of the supported ways of providing shader
+ sources.
+
+ \list
+ \li GraphicsInfo.ShaderSourceString
+ \li GraphicsInfo.ShaderSourceFile
+ \li GraphicsInfo.ShaderByteCode
+ \endlist
+
+ With OpenGL the value is GraphicsInfo.ShaderSourceString, which corresponds
+ to the traditional way of inlining GLSL source code into QML. Other,
+ non-OpenGL Qt Quick backends may however decide not to support inlined
+ shader sources, or even shader sources at all. In this case shaders are
+ expected to be pre-compiled into formats like SPIR-V or D3D shader
+ bytecode.
+
+ \note The value is only up-to-date once the item is associated with a
+ window and the window's scenegraph has initialized. Bindings relying on the
+ value have to keep this in mind since the value may change from \c 0 to the
+ actual bitmask after component initialization is complete. This is
+ particularly relevant for ShaderEffect items inside ShaderEffectSource
+ items set as property values.
+
+ \since 5.8
+ \since QtQuick 2.8
+
+ \sa shaderType, shaderCompilationType
+*/
+
+/*!
+ \qmlproperty int QtQuick::GraphicsInfo::majorVersion
+
+ This property holds the major version of the graphics API in use.
+
+ With OpenGL the default version is \c 2.0.
+
+ \sa minorVersion, profile
+ */
+
+/*!
+ \qmlproperty int QtQuick::GraphicsInfo::minorVersion
+
+ This property holds the minor version of the graphics API in use.
+
+ With OpenGL the default version is \c 2.0.
+
+ \sa majorVersion, profile
+ */
+
+/*!
+ \qmlproperty enumeration QtQuick::GraphicsInfo::profile
+
+ This property holds the configured OpenGL context profile.
+
+ The possible values are:
+ \list
+ \li GraphicsInfo.NoProfile (default) - OpenGL version is lower than 3.2 or OpenGL is not in use.
+ \li GraphicsInfo.CoreProfile - Functionality deprecated in OpenGL version 3.0 is not available.
+ \li GraphicsInfo.CompatibilityProfile - Functionality from earlier OpenGL versions is available.
+ \endlist
+
+ Reusable QML components will typically use this property in bindings in order to
+ choose between core and non core profile compatible shader sources.
+
+ \sa majorVersion, minorVersion, QSurfaceFormat
+ */
+
+/*!
+ \qmlproperty enumeration QtQuick::GraphicsInfo::renderableType
+
+ This property holds the renderable type. The value has no meaning for APIs
+ other than OpenGL.
+
+ The possible values are:
+ \list
+ \li GraphicsInfo.SurfaceFormatUnspecified (default) - Unspecified rendering method
+ \li GraphicsInfo.SurfaceFormatOpenGL - Desktop OpenGL or other graphics API
+ \li GraphicsInfo.SurfaceFormatOpenGLES - OpenGL ES
+ \endlist
+
+ \sa QSurfaceFormat
+ */
+
+void QQuickGraphicsInfo::updateInfo()
+{
+ const bool sgReady = m_window && m_window->isSceneGraphInitialized();
+
+ if (sgReady) {
+ QSGRendererInterface *rif = m_window->rendererInterface();
+ if (rif) {
+ GraphicsApi newAPI = GraphicsApi(rif->graphicsApi());
+ if (m_api != newAPI) {
+ m_api = newAPI;
+ emit apiChanged();
+ m_shaderType = ShaderType(rif->shaderType());
+ emit shaderTypeChanged();
+ m_shaderCompilationType = ShaderCompilationType(int(rif->shaderCompilationType()));
+ emit shaderCompilationTypeChanged();
+ m_shaderSourceType = ShaderSourceType(int(rif->shaderSourceType()));
+ emit shaderSourceTypeChanged();
+ }
+ }
+ }
+
+ QSurfaceFormat format = QSurfaceFormat::defaultFormat();
+#ifndef QT_NO_OPENGL
+ if (sgReady) {
+ QOpenGLContext *context = m_window->openglContext();
+ if (context)
+ format = context->format();
+ }
+#endif
+ if (m_majorVersion != format.majorVersion()) {
+ m_majorVersion = format.majorVersion();
+ emit majorVersionChanged();
+ }
+ if (m_minorVersion != format.minorVersion()) {
+ m_minorVersion = format.minorVersion();
+ emit minorVersionChanged();
+ }
+ ContextProfile profile = static_cast<ContextProfile>(format.profile());
+ if (m_profile != profile) {
+ m_profile = profile;
+ emit profileChanged();
+ }
+ RenderableType renderableType = static_cast<RenderableType>(format.renderableType());
+ if (m_renderableType != renderableType) {
+ m_renderableType = renderableType;
+ emit renderableTypeChanged();
+ }
+}
+
+void QQuickGraphicsInfo::setWindow(QQuickWindow *window)
+{
+ if (m_window != window) {
+ if (m_window) {
+ disconnect(m_window, SIGNAL(sceneGraphInitialized()), this, SLOT(updateInfo()));
+ disconnect(m_window, SIGNAL(sceneGraphInvalidated()), this, SLOT(updateInfo()));
+ }
+ if (window) {
+ connect(window, SIGNAL(sceneGraphInitialized()), this, SLOT(updateInfo()));
+ connect(window, SIGNAL(sceneGraphInvalidated()), this, SLOT(updateInfo()));
+ }
+ m_window = window;
+ }
+ updateInfo();
+}
+
+QT_END_NAMESPACE
diff --git a/src/quick/items/qquickgraphicsinfo_p.h b/src/quick/items/qquickgraphicsinfo_p.h
new file mode 100644
index 0000000000..0cbfbbddba
--- /dev/null
+++ b/src/quick/items/qquickgraphicsinfo_p.h
@@ -0,0 +1,166 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKGRAPHICSINFO_P_H
+#define QQUICKGRAPHICSINFO_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qobject.h>
+#include <QtCore/qpointer.h>
+#include <QtQml/qqml.h>
+#include <QtGui/qsurfaceformat.h>
+#include <QtQuick/qsgrendererinterface.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickItem;
+class QQuickWindow;
+
+class QQuickGraphicsInfo : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(GraphicsApi api READ api NOTIFY apiChanged FINAL)
+ Q_PROPERTY(ShaderType shaderType READ shaderType NOTIFY shaderTypeChanged FINAL)
+ Q_PROPERTY(ShaderCompilationType shaderCompilationType READ shaderCompilationType NOTIFY shaderCompilationTypeChanged FINAL)
+ Q_PROPERTY(ShaderSourceType shaderSourceType READ shaderSourceType NOTIFY shaderSourceTypeChanged FINAL)
+
+ Q_PROPERTY(int majorVersion READ majorVersion NOTIFY majorVersionChanged FINAL)
+ Q_PROPERTY(int minorVersion READ minorVersion NOTIFY minorVersionChanged FINAL)
+ Q_PROPERTY(ContextProfile profile READ profile NOTIFY profileChanged FINAL)
+ Q_PROPERTY(RenderableType renderableType READ renderableType NOTIFY renderableTypeChanged FINAL)
+
+public:
+ enum GraphicsApi {
+ Unknown = QSGRendererInterface::Unknown,
+ Software = QSGRendererInterface::Software,
+ OpenGL = QSGRendererInterface::OpenGL,
+ Direct3D12 = QSGRendererInterface::Direct3D12
+ };
+ Q_ENUM(GraphicsApi)
+
+ enum ShaderType {
+ UnknownShadingLanguage = QSGRendererInterface::UnknownShadingLanguage,
+ GLSL = QSGRendererInterface::GLSL,
+ HLSL = QSGRendererInterface::HLSL
+ };
+ Q_ENUM(ShaderType)
+
+ enum ShaderCompilationType {
+ RuntimeCompilation = QSGRendererInterface::RuntimeCompilation,
+ OfflineCompilation = QSGRendererInterface::OfflineCompilation
+ };
+ Q_ENUM(ShaderCompilationType)
+
+ enum ShaderSourceType {
+ ShaderSourceString = QSGRendererInterface::ShaderSourceString,
+ ShaderSourceFile = QSGRendererInterface::ShaderSourceFile,
+ ShaderByteCode = QSGRendererInterface::ShaderByteCode
+ };
+ Q_ENUM(ShaderSourceType)
+
+ enum ContextProfile {
+ NoProfile = QSurfaceFormat::NoProfile,
+ CoreProfile = QSurfaceFormat::CoreProfile,
+ CompatibilityProfile = QSurfaceFormat::CompatibilityProfile
+ };
+ Q_ENUM(ContextProfile)
+
+ enum RenderableType {
+ SurfaceFormatUnspecified = QSurfaceFormat::DefaultRenderableType,
+ SurfaceFormatOpenGL = QSurfaceFormat::OpenGL,
+ SurfaceFormatOpenGLES = QSurfaceFormat::OpenGLES
+ };
+ Q_ENUM(RenderableType)
+
+ QQuickGraphicsInfo(QQuickItem *item = 0);
+
+ static QQuickGraphicsInfo *qmlAttachedProperties(QObject *object);
+
+ GraphicsApi api() const { return m_api; }
+ ShaderType shaderType() const { return m_shaderType; }
+ ShaderCompilationType shaderCompilationType() const { return m_shaderCompilationType; }
+ ShaderSourceType shaderSourceType() const { return m_shaderSourceType; }
+
+ int majorVersion() const { return m_majorVersion; }
+ int minorVersion() const { return m_minorVersion; }
+ ContextProfile profile() const { return m_profile; }
+ RenderableType renderableType() const { return m_renderableType; }
+
+Q_SIGNALS:
+ void apiChanged();
+ void shaderTypeChanged();
+ void shaderCompilationTypeChanged();
+ void shaderSourceTypeChanged();
+
+ void majorVersionChanged();
+ void minorVersionChanged();
+ void profileChanged();
+ void renderableTypeChanged();
+
+private Q_SLOTS:
+ void updateInfo();
+ void setWindow(QQuickWindow *window);
+
+private:
+ QPointer<QQuickWindow> m_window;
+ GraphicsApi m_api;
+ ShaderType m_shaderType;
+ ShaderCompilationType m_shaderCompilationType;
+ ShaderSourceType m_shaderSourceType;
+ int m_majorVersion;
+ int m_minorVersion;
+ ContextProfile m_profile;
+ RenderableType m_renderableType;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPEINFO(QQuickGraphicsInfo, QML_HAS_ATTACHED_PROPERTIES)
+
+#endif // QQUICKGRAPHICSINFO_P_H
diff --git a/src/quick/items/qquickitemsmodule.cpp b/src/quick/items/qquickitemsmodule.cpp
index e5b82e1102..8ed7f2bb05 100644
--- a/src/quick/items/qquickitemsmodule.cpp
+++ b/src/quick/items/qquickitemsmodule.cpp
@@ -80,7 +80,7 @@
# include "qquickanimatedsprite_p.h"
# include "qquickopenglinfo_p.h"
#endif
-#include "qquickrendererinfo_p.h"
+#include "qquickgraphicsinfo_p.h"
#include "qquickshadereffect_p.h"
#include "qquickshadereffectmesh_p.h"
#include "qquickdrag_p.h"
@@ -294,8 +294,7 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor)
qmlRegisterUncreatableType<QQuickMouseEvent, 7>(uri, 2, 7, nullptr, QQuickMouseEvent::tr("MouseEvent is only available within handlers in MouseArea"));
- qmlRegisterType<QQuickShaderEffect, 2>(uri, 2, 8, "ShaderEffect");
- qmlRegisterUncreatableType<QQuickRendererInfo>(uri, 2, 8,"RendererInfo", QQuickRendererInfo::tr("RendererInfo is only available via attached properties"));
+ qmlRegisterUncreatableType<QQuickGraphicsInfo>(uri, 2, 8,"GraphicsInfo", QQuickGraphicsInfo::tr("GraphicsInfo is only available via attached properties"));
qmlRegisterType<QQuickBorderImageMesh>("QtQuick", 2, 8, "BorderImageMesh");
}
diff --git a/src/quick/items/qquickopenglinfo.cpp b/src/quick/items/qquickopenglinfo.cpp
index b380a93e76..4bb13b84aa 100644
--- a/src/quick/items/qquickopenglinfo.cpp
+++ b/src/quick/items/qquickopenglinfo.cpp
@@ -61,6 +61,10 @@ QT_BEGIN_NAMESPACE
format. When it becomes associated with a surface, all properties
will update.
+ \deprecated
+
+ \warning This type is deprecated. Use GraphicsInfo instead.
+
\sa ShaderEffect
*/
QQuickOpenGLInfo::QQuickOpenGLInfo(QQuickItem *item)
diff --git a/src/quick/items/qquickrendererinfo.cpp b/src/quick/items/qquickrendererinfo.cpp
deleted file mode 100644
index b31cfd7f94..0000000000
--- a/src/quick/items/qquickrendererinfo.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQuick module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qquickrendererinfo_p.h"
-#include "qquickwindow.h"
-#include "qquickitem.h"
-#include <qsgrendererinterface.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmltype RendererInfo
- \instantiates QQuickRendererInfo
- \inqmlmodule QtQuick
- \ingroup qtquick-effects
- \since 5.8
- \since QtQuick 2.8
- \brief Provides information about the used Qt Quick backend
-
- The RendererInfo attached type provides information about the scenegraph
- backend used to render the contents of the associated window.
-
- If the item to which the properties are attached is not currently
- associated with any window, the properties are set to default values. When
- the associated window changes, the properties will update.
-
- \sa OpenGLInfo, ShaderEffect
- */
-
-QQuickRendererInfo::QQuickRendererInfo(QQuickItem *item)
- : QObject(item)
- , m_window(0)
- , m_api(Unknown)
-{
- connect(item, SIGNAL(windowChanged(QQuickWindow*)), this, SLOT(setWindow(QQuickWindow*)));
- setWindow(item->window());
-}
-
-QQuickRendererInfo *QQuickRendererInfo::qmlAttachedProperties(QObject *object)
-{
- if (QQuickItem *item = qobject_cast<QQuickItem *>(object))
- return new QQuickRendererInfo(item);
-
- return nullptr;
-}
-
-/*!
- \qmlproperty enumeration QtQuick::RendererInfo::api
-
- This property describes the graphics API that is currently in use.
-
- The possible values are:
- \list
- \li RendererInfo.Unknown - the default value when no active scenegraph is associated with the item
- \li RendererInfo.Software - Qt Quick's software renderer based on QPainter with the raster paint engine
- \li RendererInfo.OpenGL - OpenGL or OpenGL ES
- \li RendererInfo.Direct3D12 - Direct3D 12
- \endlist
- */
-
-void QQuickRendererInfo::updateInfo()
-{
- GraphicsApi newAPI = Unknown;
-
- if (m_window && m_window->isSceneGraphInitialized()) {
- QSGRendererInterface *rif = m_window->rendererInterface();
- if (rif)
- newAPI = GraphicsApi(rif->graphicsApi()); // this function is safe to call on the gui/main thread too
- }
-
- if (m_api != newAPI) {
- m_api = newAPI;
- emit apiChanged();
- }
-}
-
-void QQuickRendererInfo::setWindow(QQuickWindow *window)
-{
- if (m_window != window) {
- if (m_window) {
- disconnect(m_window, SIGNAL(sceneGraphInitialized()), this, SLOT(updateInfo()));
- disconnect(m_window, SIGNAL(sceneGraphInvalidated()), this, SLOT(updateInfo()));
- }
- if (window) {
- connect(window, SIGNAL(sceneGraphInitialized()), this, SLOT(updateInfo()));
- connect(window, SIGNAL(sceneGraphInvalidated()), this, SLOT(updateInfo()));
- }
- m_window = window;
- }
- updateInfo();
-}
-
-QT_END_NAMESPACE
diff --git a/src/quick/items/qquickrendererinfo_p.h b/src/quick/items/qquickrendererinfo_p.h
deleted file mode 100644
index d0298baa21..0000000000
--- a/src/quick/items/qquickrendererinfo_p.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQuick module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QQUICKRENDERERINFO_P_H
-#define QQUICKRENDERERINFO_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qobject.h>
-#include <QtCore/qpointer.h>
-#include <QtQml/qqml.h>
-
-QT_BEGIN_NAMESPACE
-
-class QQuickItem;
-class QQuickWindow;
-
-class QQuickRendererInfo : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(GraphicsApi api READ api NOTIFY apiChanged FINAL)
-
-public:
- // must match QSGRendererInterface
- enum GraphicsApi {
- Unknown,
- Software,
- OpenGL,
- Direct3D12
- };
- Q_ENUM(GraphicsApi)
-
- QQuickRendererInfo(QQuickItem *item = 0);
-
- static QQuickRendererInfo *qmlAttachedProperties(QObject *object);
-
- GraphicsApi api() const { return m_api; }
-
-Q_SIGNALS:
- void apiChanged();
-
-private Q_SLOTS:
- void updateInfo();
- void setWindow(QQuickWindow *window);
-
-private:
- QPointer<QQuickWindow> m_window;
- GraphicsApi m_api;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPEINFO(QQuickRendererInfo, QML_HAS_ATTACHED_PROPERTIES)
-
-#endif // QQUICKRENDERERINFO_P_H
diff --git a/src/quick/items/qquickshadereffect.cpp b/src/quick/items/qquickshadereffect.cpp
index 1fbc9c201f..f7fc7880ed 100644
--- a/src/quick/items/qquickshadereffect.cpp
+++ b/src/quick/items/qquickshadereffect.cpp
@@ -174,7 +174,7 @@ QT_BEGIN_NAMESPACE
Direct3D backends provide ShaderEffect support with HLSL. The Direct3D 12
backend requires using at least Shader Model 5.0 both for vertex and pixel
- shaders. When necessary, the \l shaderType property can be used to decide
+ shaders. When necessary, GraphicsInfo.shaderType can be used to decide
at runtime what kind of value to assign to \l fragmentShader or
\l vertexShader.
@@ -212,8 +212,8 @@ QT_BEGIN_NAMESPACE
Unlike with OpenGL, runtime compilation of shader source code may not be
supported. Backends for modern APIs are likely to prefer offline
compilation and shipping pre-compiled bytecode with applications instead of
- inlined shader source strings. See the \l shaderSourceType and
- \l shaderCompilationType properties.
+ inlined shader source strings. To check what is expected at runtime, use the
+ GraphicsInfo.shaderSourceType and GraphicsInfo.shaderCompilationType properties.
\table 70%
\row
@@ -399,7 +399,7 @@ QQuickShaderEffect::QQuickShaderEffect(QQuickItem *parent)
\c{float4 position : SV_POSITION} (names can differ since linking is done
based on the semantics).
- \sa vertexShader, shaderType, shaderCompilationType, shaderSourceType
+ \sa vertexShader, GraphicsInfo
*/
QByteArray QQuickShaderEffect::fragmentShader() const
@@ -438,7 +438,7 @@ void QQuickShaderEffect::setFragmentShader(const QByteArray &code)
enough to use the standard \c TEXCOORD0 semantic, for example
\c{float2 coord : TEXCOORD0}.
- \sa fragmentShader, shaderType, shaderCompilationType, shaderSourceType
+ \sa fragmentShader, GraphicsInfo
*/
QByteArray QQuickShaderEffect::vertexShader() const
@@ -652,118 +652,6 @@ QQuickShaderEffect::Status QQuickShaderEffect::status() const
return m_impl->status();
}
-/*!
- \qmlproperty enumeration QtQuick::ShaderEffect::shaderType
-
- This property contains the shading language supported by the current Qt
- Quick backend the application is using.
-
- \list
- \li ShaderEffect.UnknownShadingLanguage - Not yet known due to no window and scenegraph associated
- \li ShaderEffect.GLSL - GLSL or GLSL ES
- \li ShaderEffect.HLSL - HLSL
- \endlist
-
- \note The value is only up-to-date once the item is associated with a
- window and the window's scenegraph has initialized. Bindings relying on the
- value have to keep this in mind since the value may change from
- ShaderEffect.UnknownShadingLanguage to the actual value after component
- initialization is complete. This is particularly relevant for ShaderEffect
- items inside ShaderEffectSource items set as property values.
-
- \since 5.8
- \since QtQuick 2.8
-
- \sa shaderCompilationType, shaderSourceType, vertexShader, fragmentShader
-*/
-
-QQuickShaderEffect::ShaderType QQuickShaderEffect::shaderType() const
-{
-#ifndef QT_NO_OPENGL
- if (m_glImpl)
- return GLSL;
-#endif
- return m_impl->shaderType();
-}
-
-/*!
- \qmlproperty enumeration QtQuick::ShaderEffect::shaderCompilationType
-
- This property contains a bitmask of the shader compilation approaches
- supported by the current Qt Quick backend the application is using.
-
- \list
- \li ShaderEffect.RuntimeCompilation
- \li ShaderEffect.OfflineCompilation
- \endlist
-
- With OpenGL the value is ShaderEffect.RuntimeCompilation, which corresponds
- to the traditional way of using ShaderEffect. Non-OpenGL backends are
- expected to focus more on ShaderEffect.OfflineCompilation, however.
-
- \note The value is only up-to-date once the item is associated with a
- window and the window's scenegraph has initialized. Bindings relying on the
- value have to keep this in mind since the value may change from \c 0 to the
- actual bitmask after component initialization is complete. This is
- particularly relevant for ShaderEffect items inside ShaderEffectSource
- items set as property values.
-
- \since 5.8
- \since QtQuick 2.8
-
- \sa shaderType, shaderSourceType, vertexShader, fragmentShader
-*/
-
-QQuickShaderEffect::ShaderCompilationType QQuickShaderEffect::shaderCompilationType() const
-{
-#ifndef QT_NO_OPENGL
- if (m_glImpl)
- return RuntimeCompilation;
-#endif
- return m_impl->shaderCompilationType();
-}
-
-/*!
- \qmlproperty enumeration QtQuick::ShaderEffect::shaderSourceType
-
- This property contains a bitmask of the supported ways of providing shader
- sources.
-
- \list
- \li ShaderEffect.ShaderSourceString
- \li ShaderEffect.ShaderSourceFile
- \li ShaderEffect.ShaderByteCode
- \endlist
-
- With OpenGL the value is ShaderEffect.ShaderSourceString, which corresponds
- to the traditional way of inlining GLSL source code into QML. Other,
- non-OpenGL Qt Quick backends may however decide not to support inlined
- shader sources, or even shader sources at all. In this case shaders are
- expected to be pre-compiled into formats like SPIR-V or D3D shader
- bytecode.
-
- \note The value is only up-to-date once the item is associated with a
- window and the window's scenegraph has initialized. Bindings relying on the
- value have to keep this in mind since the value may change from \c 0 to the
- actual bitmask after component initialization is complete. This is
- particularly relevant for ShaderEffect items inside ShaderEffectSource
- items set as property values.
-
- \since 5.8
- \since QtQuick 2.8
-
- \sa shaderType, shaderCompilationType, vertexShader, fragmentShader
-*/
-
-QQuickShaderEffect::ShaderSourceType QQuickShaderEffect::shaderSourceType() const
-{
-#ifndef QT_NO_OPENGL
- if (m_glImpl)
- return ShaderSourceString;
-#endif
- return m_impl->shaderSourceType();
-}
-
bool QQuickShaderEffect::event(QEvent *e)
{
#ifndef QT_NO_OPENGL
diff --git a/src/quick/items/qquickshadereffect_p.h b/src/quick/items/qquickshadereffect_p.h
index 0410514c36..62d7e6fe5f 100644
--- a/src/quick/items/qquickshadereffect_p.h
+++ b/src/quick/items/qquickshadereffect_p.h
@@ -70,9 +70,6 @@ class Q_QUICK_PRIVATE_EXPORT QQuickShaderEffect : public QQuickItem
Q_PROPERTY(QString log READ log NOTIFY logChanged)
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
Q_PROPERTY(bool supportsAtlasTextures READ supportsAtlasTextures WRITE setSupportsAtlasTextures NOTIFY supportsAtlasTexturesChanged REVISION 1)
- Q_PROPERTY(ShaderType shaderType READ shaderType NOTIFY shaderTypeChanged REVISION 2)
- Q_PROPERTY(ShaderCompilationType shaderCompilationType READ shaderCompilationType NOTIFY shaderCompilationTypeChanged REVISION 2)
- Q_PROPERTY(ShaderSourceType shaderSourceType READ shaderSourceType NOTIFY shaderSourceTypeChanged REVISION 2)
public:
enum CullMode {
@@ -89,26 +86,6 @@ public:
};
Q_ENUM(Status)
- enum ShaderType {
- UnknownShadingLanguage,
- GLSL,
- HLSL
- };
- Q_ENUM(ShaderType)
-
- enum ShaderCompilationType {
- RuntimeCompilation = 0x01,
- OfflineCompilation = 0x02
- };
- Q_ENUM(ShaderCompilationType)
-
- enum ShaderSourceType {
- ShaderSourceString = 0x01,
- ShaderSourceFile = 0x02,
- ShaderByteCode = 0x04
- };
- Q_ENUM(ShaderSourceType)
-
QQuickShaderEffect(QQuickItem *parent = 0);
QByteArray fragmentShader() const;
@@ -132,10 +109,6 @@ public:
QString log() const;
Status status() const;
- ShaderType shaderType() const;
- ShaderCompilationType shaderCompilationType() const;
- ShaderSourceType shaderSourceType() const;
-
bool isComponentComplete() const;
QString parseLog();
@@ -148,9 +121,6 @@ Q_SIGNALS:
void logChanged();
void statusChanged();
void supportsAtlasTexturesChanged();
- void shaderTypeChanged();
- void shaderCompilationTypeChanged();
- void shaderSourceTypeChanged();
protected:
bool event(QEvent *e) override;