From: Laszlo Agocs Date: Thu, 7 Aug 2014 15:19:50 +0000 (+0200) Subject: Remove setDefaultFormat() from QQuickWindow X-Git-Tag: v5.3.99+beta1~183 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f03892bbe9f017459d72e15943dc35ac86a681bf;p=platform%2Fupstream%2Fqtdeclarative.git Remove setDefaultFormat() from QQuickWindow Replaced by QSurfaceFormat::setDefaultFormat(). Change-Id: If4e37b75ccb55d556d80b0079be89e5a521f6dbb Reviewed-by: Gunnar Sletta --- diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index 0b82cd3..d3b0dc0 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 04a89b1..7757168 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 93ceefe..c8f156e 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 beforeSynchronizingJobs; QList afterSynchronizingJobs; diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp index cf980df..67a5f25 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 b8e36b0..3acf8a5 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()