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>
This commit is contained in:
parent
18bb8d6b16
commit
560d33ad04
@ -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()
|
||||
*/
|
||||
@ -334,6 +346,63 @@ bool QSurfaceFormat::testOption(QSurfaceFormat::FormatOptions opt) const
|
||||
return d->opts & opt;
|
||||
}
|
||||
|
||||
/*!
|
||||
\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.
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user