aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@digia.com>2014-08-07 17:19:50 +0200
committerLaszlo Agocs <laszlo.agocs@digia.com>2014-08-11 13:19:38 +0200
commitf03892bbe9f017459d72e15943dc35ac86a681bf (patch)
tree6e751dd0e6af3c94a75b1fadfe7e3805fd116084
parent126c06586849ca41c7d13b833cb8af98d3873b4b (diff)
Remove setDefaultFormat() from QQuickWindow
Replaced by QSurfaceFormat::setDefaultFormat(). Change-Id: If4e37b75ccb55d556d80b0079be89e5a521f6dbb Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
-rw-r--r--src/quick/items/qquickwindow.cpp73
-rw-r--r--src/quick/items/qquickwindow.h3
-rw-r--r--src/quick/items/qquickwindow_p.h3
-rw-r--r--src/quick/scenegraph/qsgcontext.cpp2
-rw-r--r--tests/auto/quick/qquickwindow/tst_qquickwindow.cpp16
5 files changed, 27 insertions, 70 deletions
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 0b82cd3441..d3b0dc05d0 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -87,8 +87,6 @@ Q_LOGGING_CATEGORY(DBG_DIRTY, "qt.quick.dirty");
extern Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha);
bool QQuickWindowPrivate::defaultAlphaBuffer = false;
-bool QQuickWindowPrivate::defaultFormatInitialized = false;
-QSurfaceFormat QQuickWindowPrivate::defaultFormat;
void QQuickWindowPrivate::updateFocusItemTransform()
{
@@ -466,7 +464,7 @@ void QQuickWindowPrivate::init(QQuickWindow *c, QQuickRenderControl *control)
}
q->setSurfaceType(windowManager ? windowManager->windowSurfaceType() : QSurface::OpenGLSurface);
- q->setFormat(q->defaultFormat());
+ q->setFormat(sg->defaultSurfaceFormat());
animationController = new QQuickAnimatorController();
animationController->m_window = q;
@@ -1055,8 +1053,18 @@ void QQuickWindowPrivate::cleanup(QSGNode *n)
\note All classes with QSG prefix should be used solely on the scene graph's
rendering thread. See \l {Scene Graph and Rendering} for more information.
- \sa {Scene Graph - OpenGL Under QML}
+ \section2 Context and surface formats
+ While it is possible to specify a QSurfaceFormat for every QQuickWindow by
+ calling the member function setFormat(), windows may also be created from
+ QML by using the Window and ApplicationWindow elements. In this case there
+ is no C++ code involved in the creation of the window instance, yet
+ applications may still wish to set certain surface format values, for
+ example to request a given OpenGL version or profile. Such applications can
+ call the static function QSurfaceFormat::setDefaultFormat() at startup. The
+ specified format will be used for all Quick windows created afterwards.
+
+ \sa {Scene Graph - OpenGL Under QML}
*/
/*!
@@ -3535,11 +3543,7 @@ bool QQuickWindow::hasDefaultAlphaBuffer()
In any application which expects to create translucent windows, it's necessary to set
this to true before creating the first QQuickWindow. The default value is false.
- \note This function affects the size of the alpha buffer in the format returned by
- defaultFormat(). Enabling alpha via this function and passing a format with alpha
- buffer size 8 to setDefaultFormat() are equivalent.
-
- \sa hasDefaultAlphaBuffer(), setDefaultFormat(), defaultFormat()
+ \sa hasDefaultAlphaBuffer()
*/
void QQuickWindow::setDefaultAlphaBuffer(bool useAlpha)
{
@@ -3619,53 +3623,6 @@ void QQuickWindow::resetOpenGLState()
}
/*!
- \brief QQuickWindow::setDefaultFormat
- \since 5.4
- @brief Sets the global default surface format that is used for all new QQuickWindow instances.
-
- While it is possible to specify a QSurfaceFormat for every QQuickWindow by
- calling the member function setFormat(), windows may also be created from
- QML by using the Window and ApplicationWindow elements. In this case there
- is no C++ code involved in the creation of the window instance, yet
- applications may still wish to set certain surface format values, for
- example to request a given OpenGL version or profile. Such applications can
- call this static functions in main(). \a format will be used for all Quick
- windows created afterwards.
-
- \note The default value for the default format is not necessarily a
- default-constructed QSurfaceFormat. It may already have depth, stencil and alpha
- buffer sizes set. Unless there is a need to change all these sizes, the format should
- first be queried via defaultFormat() and the changes should be applied to that,
- instead of merely starting with a default-constructed QSurfaceFormat.
-
- \sa setFormat(), format(), defaultFormat()
- */
-void QQuickWindow::setDefaultFormat(const QSurfaceFormat &format)
-{
- QQuickWindowPrivate::defaultFormatInitialized = true;
- QQuickWindowPrivate::defaultFormat = format;
-}
-
-/*!
- \brief QQuickWindow::defaultFormat
- \since 5.4
-
- \return The global default surface format that is used for all QQuickWindow instances.
-
- \note This function requires a QGuiApplication or QApplication instance.
-
- \sa setDefaultFormat()
- */
-QSurfaceFormat QQuickWindow::defaultFormat()
-{
- if (!QQuickWindowPrivate::defaultFormatInitialized) {
- QQuickWindowPrivate::defaultFormatInitialized = true;
- QQuickWindowPrivate::defaultFormat = QSGRenderLoop::instance()->sceneGraphContext()->defaultSurfaceFormat();
- }
- return QQuickWindowPrivate::defaultFormat;
-}
-
-/*!
\brief QQuickWindow::glslVersion
\since 5.4
\return The OpenGL Shading Language version for this window.
@@ -3687,7 +3644,7 @@ QSurfaceFormat QQuickWindow::defaultFormat()
OpenGL 2 style shaders. The most important for reusable components is to check for
core profiles since these do not accept shaders with the old syntax.
- \sa setFormat(), setDefaultFormat(), glslIsCoreProfile()
+ \sa setFormat(), glslIsCoreProfile()
*/
QString QQuickWindow::glslVersion() const
{
@@ -3738,7 +3695,7 @@ QString QQuickWindow::glslVersion() const
To retrieve more information about the shading language, use glslVersion().
- \sa glslVersion(), setFormat(), setDefaultFormat()
+ \sa glslVersion(), setFormat()
*/
bool QQuickWindow::glslIsCoreProfile() const
{
diff --git a/src/quick/items/qquickwindow.h b/src/quick/items/qquickwindow.h
index 04a89b1d3d..7757168aa3 100644
--- a/src/quick/items/qquickwindow.h
+++ b/src/quick/items/qquickwindow.h
@@ -150,9 +150,6 @@ public:
QOpenGLContext *openglContext() const;
- static void setDefaultFormat(const QSurfaceFormat &format);
- static QSurfaceFormat defaultFormat();
-
QString glslVersion() const;
bool glslIsCoreProfile() const;
diff --git a/src/quick/items/qquickwindow_p.h b/src/quick/items/qquickwindow_p.h
index 93ceefe5af..c8f156ed37 100644
--- a/src/quick/items/qquickwindow_p.h
+++ b/src/quick/items/qquickwindow_p.h
@@ -258,9 +258,6 @@ public:
QString *untranslatedMessage,
bool isEs);
- static bool defaultFormatInitialized;
- static QSurfaceFormat defaultFormat;
-
QMutex renderJobMutex;
QList<QRunnable *> beforeSynchronizingJobs;
QList<QRunnable *> afterSynchronizingJobs;
diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp
index cf980dfbd4..67a5f25405 100644
--- a/src/quick/scenegraph/qsgcontext.cpp
+++ b/src/quick/scenegraph/qsgcontext.cpp
@@ -310,7 +310,7 @@ QSGNinePatchNode *QSGContext::createQStyleNode()
QSurfaceFormat QSGContext::defaultSurfaceFormat() const
{
- QSurfaceFormat format;
+ QSurfaceFormat format = QSurfaceFormat::defaultFormat();
static bool useDepth = qEnvironmentVariableIsEmpty("QSG_NO_DEPTH_BUFFER");
static bool useStencil = qEnvironmentVariableIsEmpty("QSG_NO_STENCIL_BUFFER");
format.setDepthBufferSize(useDepth ? 24 : 0);
diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
index b8e36b06fb..3acf8a5f07 100644
--- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
+++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
@@ -1912,12 +1912,10 @@ void tst_qquickwindow::defaultSurfaceFormat()
// least using some harmless settings to check that the global, static format is
// taken into account in the requested format.
- QSurfaceFormat savedDefaultFormat = QQuickWindow::defaultFormat();
+ QSurfaceFormat savedDefaultFormat = QSurfaceFormat::defaultFormat();
// Verify that depth and stencil are set, as they should be, unless they are disabled
// via environment variables.
- QVERIFY(savedDefaultFormat.depthBufferSize() >= 16);
- QVERIFY(savedDefaultFormat.stencilBufferSize() >= 8);
QSurfaceFormat format = savedDefaultFormat;
format.setSwapInterval(0);
@@ -1926,7 +1924,9 @@ void tst_qquickwindow::defaultSurfaceFormat()
format.setBlueBufferSize(8);
format.setProfile(QSurfaceFormat::CompatibilityProfile);
format.setOption(QSurfaceFormat::DebugContext);
- QQuickWindow::setDefaultFormat(format);
+ // Will not set depth and stencil. That should be added automatically,
+ // unless the are disabled (but they aren't).
+ QSurfaceFormat::setDefaultFormat(format);
QQuickWindow window;
window.show();
@@ -1940,7 +1940,13 @@ void tst_qquickwindow::defaultSurfaceFormat()
QCOMPARE(format.profile(), reqFmt.profile());
QCOMPARE(int(format.options()), int(reqFmt.options()));
- QQuickWindow::setDefaultFormat(savedDefaultFormat);
+ // Depth and stencil should be >= what has been requested. For real. But use
+ // the context since the window's surface format is only partially updated
+ // on most platforms.
+ QVERIFY(window.openglContext()->format().depthBufferSize() >= 16);
+ QVERIFY(window.openglContext()->format().stencilBufferSize() >= 8);
+
+ QSurfaceFormat::setDefaultFormat(savedDefaultFormat);
}
void tst_qquickwindow::glslVersion()