Normalize rounding
Change the rounding of negative half values to match standard C++ round, this will also allow future optimizations. Change-Id: I8f8c71bed1f05891e82ea787c6bc284297de9c5c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
c5f611c084
commit
8c8b9a4173
@ -973,7 +973,7 @@ static_assert((std::is_same<qsizetype, qptrdiff>::value));
|
|||||||
|
|
||||||
Rounds \a d to the nearest integer.
|
Rounds \a d to the nearest integer.
|
||||||
|
|
||||||
Rounds half up (e.g. 0.5 -> 1, -0.5 -> 0).
|
Rounds half away from zero (e.g. 0.5 -> 1, -0.5 -> -1).
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
@ -985,7 +985,7 @@ static_assert((std::is_same<qsizetype, qptrdiff>::value));
|
|||||||
|
|
||||||
Rounds \a d to the nearest integer.
|
Rounds \a d to the nearest integer.
|
||||||
|
|
||||||
Rounds half up (e.g. 0.5f -> 1, -0.5f -> 0).
|
Rounds half away from zero (e.g. 0.5f -> 1, -0.5f -> -1).
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
@ -997,7 +997,7 @@ static_assert((std::is_same<qsizetype, qptrdiff>::value));
|
|||||||
|
|
||||||
Rounds \a d to the nearest 64-bit integer.
|
Rounds \a d to the nearest 64-bit integer.
|
||||||
|
|
||||||
Rounds half up (e.g. 0.5 -> 1, -0.5 -> 0).
|
Rounds half away from zero (e.g. 0.5 -> 1, -0.5 -> -1).
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
@ -1009,7 +1009,7 @@ static_assert((std::is_same<qsizetype, qptrdiff>::value));
|
|||||||
|
|
||||||
Rounds \a d to the nearest 64-bit integer.
|
Rounds \a d to the nearest 64-bit integer.
|
||||||
|
|
||||||
Rounds half up (e.g. 0.5f -> 1, -0.5f -> 0).
|
Rounds half away from zero (e.g. 0.5f -> 1, -0.5f -> -1).
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
|
@ -582,14 +582,14 @@ template <typename T>
|
|||||||
constexpr inline T qAbs(const T &t) { return t >= 0 ? t : -t; }
|
constexpr inline T qAbs(const T &t) { return t >= 0 ? t : -t; }
|
||||||
|
|
||||||
constexpr inline int qRound(double d)
|
constexpr inline int qRound(double d)
|
||||||
{ return d >= 0.0 ? int(d + 0.5) : int(d - double(int(d-1)) + 0.5) + int(d-1); }
|
{ return d >= 0.0 ? int(d + 0.5) : int(d - 0.5); }
|
||||||
constexpr inline int qRound(float d)
|
constexpr inline int qRound(float d)
|
||||||
{ return d >= 0.0f ? int(d + 0.5f) : int(d - float(int(d-1)) + 0.5f) + int(d-1); }
|
{ return d >= 0.0f ? int(d + 0.5f) : int(d - 0.5f); }
|
||||||
|
|
||||||
constexpr inline qint64 qRound64(double d)
|
constexpr inline qint64 qRound64(double d)
|
||||||
{ return d >= 0.0 ? qint64(d + 0.5) : qint64(d - double(qint64(d-1)) + 0.5) + qint64(d-1); }
|
{ return d >= 0.0 ? qint64(d + 0.5) : qint64(d - 0.5); }
|
||||||
constexpr inline qint64 qRound64(float d)
|
constexpr inline qint64 qRound64(float d)
|
||||||
{ return d >= 0.0f ? qint64(d + 0.5f) : qint64(d - float(qint64(d-1)) + 0.5f) + qint64(d-1); }
|
{ return d >= 0.0f ? qint64(d + 0.5f) : qint64(d - 0.5f); }
|
||||||
|
|
||||||
namespace QTypeTraits {
|
namespace QTypeTraits {
|
||||||
|
|
||||||
|
@ -381,7 +381,7 @@ void tst_QPointF::toPoint_data()
|
|||||||
|
|
||||||
QTest::newRow("(0.0, 0.0) ==> (0, 0)") << QPointF(0, 0) << QPoint(0, 0);
|
QTest::newRow("(0.0, 0.0) ==> (0, 0)") << QPointF(0, 0) << QPoint(0, 0);
|
||||||
QTest::newRow("(0.5, 0.5) ==> (1, 1)") << QPointF(0.5, 0.5) << QPoint(1, 1);
|
QTest::newRow("(0.5, 0.5) ==> (1, 1)") << QPointF(0.5, 0.5) << QPoint(1, 1);
|
||||||
QTest::newRow("(-0.5, -0.5) ==> (0, 0)") << QPointF(-0.5, -0.5) << QPoint(0, 0);
|
QTest::newRow("(-0.5, -0.5) ==> (-1, -1)") << QPointF(-0.5, -0.5) << QPoint(-1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QPointF::toPoint()
|
void tst_QPointF::toPoint()
|
||||||
|
@ -4840,6 +4840,7 @@ public:
|
|||||||
{
|
{
|
||||||
setFlag(QGraphicsItem::ItemIsFocusable, true);
|
setFlag(QGraphicsItem::ItemIsFocusable, true);
|
||||||
setFlag(QGraphicsItem::ItemAcceptsInputMethod, true);
|
setFlag(QGraphicsItem::ItemAcceptsInputMethod, true);
|
||||||
|
setPen(Qt::NoPen); // Avoid adding a half pixel border to the rect.
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant inputMethodQuery(Qt::InputMethodQuery) const override
|
QVariant inputMethodQuery(Qt::InputMethodQuery) const override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user