Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickgraphicsinfo.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5#include <private/qquickitem_p.h>
6#include <qopenglcontext.h>
7
9
28 : QObject(item)
29 , m_window(nullptr)
30 , m_api(Unknown)
31 , m_shaderType(UnknownShadingLanguage)
32 , m_shaderCompilationType(ShaderCompilationType(0))
33 , m_shaderSourceType(ShaderSourceType(0))
34 , m_majorVersion(2)
35 , m_minorVersion(0)
36 , m_profile(OpenGLNoProfile)
37 , m_renderableType(SurfaceFormatUnspecified)
38{
39 if (Q_LIKELY(item)) {
40 connect(item, &QQuickItem::windowChanged, this, &QQuickGraphicsInfo::setWindow);
41 setWindow(item->window());
42 }
43}
44
46{
47 if (QQuickItem *item = qobject_cast<QQuickItem *>(object))
48 return new QQuickGraphicsInfo(item);
49
50 return nullptr;
51}
52
209void QQuickGraphicsInfo::updateInfo()
210{
211 // The queries via the RIF do not depend on isSceneGraphInitialized(), they only need a window.
212 if (m_window) {
213 QSGRendererInterface *rif = m_window->rendererInterface();
214 if (rif) {
215 GraphicsApi newAPI = GraphicsApi(rif->graphicsApi());
216 if (m_api != newAPI) {
217 m_api = newAPI;
219 m_shaderType = ShaderType(rif->shaderType());
221 m_shaderCompilationType = ShaderCompilationType(int(rif->shaderCompilationType()));
223 m_shaderSourceType = ShaderSourceType(int(rif->shaderSourceType()));
225 }
226 }
227 }
228
230#if QT_CONFIG(opengl)
231 if (m_window && m_window->isSceneGraphInitialized()) {
232 QOpenGLContext *context = QQuickWindowPrivate::get(m_window)->openglContext();
233 if (context)
234 format = context->format();
235 }
236#endif
237 if (m_majorVersion != format.majorVersion()) {
238 m_majorVersion = format.majorVersion();
240 }
241 if (m_minorVersion != format.minorVersion()) {
242 m_minorVersion = format.minorVersion();
244 }
246 if (m_profile != profile) {
247 m_profile = profile;
249 }
250 RenderableType renderableType = static_cast<RenderableType>(format.renderableType());
251 if (m_renderableType != renderableType) {
252 m_renderableType = renderableType;
254 }
255}
256
257void QQuickGraphicsInfo::setWindow(QQuickWindow *window)
258{
259 if (m_window != window) {
260 if (m_window) {
261 disconnect(m_window, SIGNAL(sceneGraphInitialized()), this, SLOT(updateInfo()));
262 disconnect(m_window, SIGNAL(sceneGraphInvalidated()), this, SLOT(updateInfo()));
263 }
264 if (window) {
265 connect(window, SIGNAL(sceneGraphInitialized()), this, SLOT(updateInfo()));
266 connect(window, SIGNAL(sceneGraphInvalidated()), this, SLOT(updateInfo()));
267 }
268 m_window = window;
269 }
270 updateInfo();
271}
272
274
275#include "moc_qquickgraphicsinfo_p.cpp"
QGraphicsWidget * window() const
\inmodule QtCore
Definition qobject.h:103
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
\inmodule QtGui
void minorVersionChanged()
void renderableTypeChanged()
static QQuickGraphicsInfo * qmlAttachedProperties(QObject *object)
void shaderCompilationTypeChanged()
QQuickGraphicsInfo(QQuickItem *item=nullptr)
\qmltype GraphicsInfo \instantiates QQuickGraphicsInfo \inqmlmodule QtQuick
void majorVersionChanged()
OpenGLContextProfile profile
void shaderSourceTypeChanged()
RenderableType renderableType
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
static QQuickWindowPrivate * get(QQuickWindow *c)
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
An interface providing access to some of the graphics API specific internals of the scenegraph.
The QSurfaceFormat class represents the format of a QSurface. \inmodule QtGui.
static QSurfaceFormat defaultFormat()
Returns the global default surface format.
Combined button and popup list for selecting options.
static void * context
#define Q_LIKELY(x)
#define SLOT(a)
Definition qobjectdefs.h:52
#define SIGNAL(a)
Definition qobjectdefs.h:53
GLint GLsizei GLsizei GLenum format
#define emit
QObject::connect nullptr
myObject disconnect()
[26]
QGraphicsItem * item
aWidget window() -> setWindowTitle("New Window Title")
[2]