diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2013-11-07 10:44:28 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-07 18:00:28 +0100 |
commit | 560d33ad0489aab17799ab5166ebadf9150d680a (patch) | |
tree | 59a79c334936f350317d174c189af5ef99f23232 /src/gui/kernel | |
parent | 18bb8d6b16548c669f8dfe33a865f7f1cff80e1d (diff) |
Introduce proper QSurfaceFormat's setters/testers for format options
Fixes several things
* setOption(options) has the wrong name (singular)
* setOption(options) doesn't set the current options to the argument, but
ORs the current options with the argument and sets the result
* testOption(options) has the wrong name
The old methods get deprecated, and new methods and overloads get
introduced here. Old code behavior is thereby preserved.
Change-Id: I51bba49f22810c80e6b4980892600d616503af6b
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
Diffstat (limited to 'src/gui/kernel')
-rw-r--r-- | src/gui/kernel/qsurfaceformat.cpp | 75 | ||||
-rw-r--r-- | src/gui/kernel/qsurfaceformat.h | 9 |
2 files changed, 79 insertions, 5 deletions
diff --git a/src/gui/kernel/qsurfaceformat.cpp b/src/gui/kernel/qsurfaceformat.cpp index 2f1b30ae4a..ebfd71b4d3 100644 --- a/src/gui/kernel/qsurfaceformat.cpp +++ b/src/gui/kernel/qsurfaceformat.cpp @@ -311,9 +311,15 @@ void QSurfaceFormat::setSamples(int numSamples) } /*! - Sets the format option to \a opt. + \obsolete + \overload - \sa testOption() + Use setOption(QSurfaceFormat::FormatOption, bool) or setOptions() instead. + + Sets the format options to the OR combination of \a opt and the + current format options. + + \sa options(), testOption() */ void QSurfaceFormat::setOption(QSurfaceFormat::FormatOptions opt) { @@ -325,7 +331,13 @@ void QSurfaceFormat::setOption(QSurfaceFormat::FormatOptions opt) } /*! - Returns \c true if format option \a opt is set; otherwise returns \c false. + \obsolete + \overload + + Use testOption(QSurfaceFormat::FormatOption) instead. + + Returns \c true if any of the options in \a opt is currently set + on this object; otherwise returns false. \sa setOption() */ @@ -335,6 +347,63 @@ bool QSurfaceFormat::testOption(QSurfaceFormat::FormatOptions opt) const } /*! + \since 5.3 + + Sets the format options to \a options. + + \sa options(), testOption() +*/ +void QSurfaceFormat::setOptions(QSurfaceFormat::FormatOptions options) +{ + if (int(d->opts) != int(options)) { + detach(); + d->opts = options; + } +} + +/*! + \since 5.3 + + Sets the format option \a option if \a on is true; otherwise, clears the option. + + \sa setOptions(), options(), testOption() +*/ +void QSurfaceFormat::setOption(QSurfaceFormat::FormatOption option, bool on) +{ + if (testOption(option) == on) + return; + detach(); + if (on) + d->opts |= option; + else + d->opts &= ~option; +} + +/*! + \since 5.3 + + Returns true if the format option \a option is set; otherwise returns false. + + \sa options(), testOption() +*/ +bool QSurfaceFormat::testOption(QSurfaceFormat::FormatOption option) const +{ + return d->opts & option; +} + +/*! + \since 5.3 + + Returns the currently set format options. + + \sa setOption(), setOptions(), testOption() +*/ +QSurfaceFormat::FormatOptions QSurfaceFormat::options() const +{ + return d->opts; +} + +/*! Set the minimum depth buffer size to \a size. \sa depthBufferSize() diff --git a/src/gui/kernel/qsurfaceformat.h b/src/gui/kernel/qsurfaceformat.h index 7c3c846df3..d182aa9f13 100644 --- a/src/gui/kernel/qsurfaceformat.h +++ b/src/gui/kernel/qsurfaceformat.h @@ -127,8 +127,13 @@ public: bool stereo() const; void setStereo(bool enable); - void setOption(QSurfaceFormat::FormatOptions opt); - bool testOption(QSurfaceFormat::FormatOptions opt) const; + QT_DEPRECATED void setOption(QSurfaceFormat::FormatOptions opt); + QT_DEPRECATED bool testOption(QSurfaceFormat::FormatOptions opt) const; + + void setOptions(QSurfaceFormat::FormatOptions options); + void setOption(FormatOption option, bool on = true); + bool testOption(FormatOption option) const; + QSurfaceFormat::FormatOptions options() const; private: QSurfaceFormatPrivate *d; |