summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qsurfaceformat.cpp
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2013-11-07 10:44:28 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-07 18:00:28 +0100
commit560d33ad0489aab17799ab5166ebadf9150d680a (patch)
tree59a79c334936f350317d174c189af5ef99f23232 /src/gui/kernel/qsurfaceformat.cpp
parent18bb8d6b16548c669f8dfe33a865f7f1cff80e1d (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/qsurfaceformat.cpp')
-rw-r--r--src/gui/kernel/qsurfaceformat.cpp75
1 files changed, 72 insertions, 3 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()