summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authormae <qt-info@nokia.com>2009-04-09 10:23:05 (GMT)
committermae <qt-info@nokia.com>2009-04-09 10:23:05 (GMT)
commit7f0b685d8cc56bece74585af8e74454185dc785a (patch)
tree52bd5e544a63f190a50358b0a491c0ec8a164d80 /src/gui
parentf3ee66750d279fb3d44cd13307312b703c77172f (diff)
parent8da880e77db04cc4509e0f48e0b5b1d6265da223 (diff)
downloadQt-7f0b685d8cc56bece74585af8e74454185dc785a.zip
Qt-7f0b685d8cc56bece74585af8e74454185dc785a.tar.gz
Qt-7f0b685d8cc56bece74585af8e74454185dc785a.tar.bz2
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp10
-rw-r--r--src/gui/graphicsview/qgraphicsitem_p.h2
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp4
-rw-r--r--src/gui/inputmethod/qmacinputcontext_mac.cpp20
-rw-r--r--src/gui/inputmethod/qmacinputcontext_p.h5
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm14
-rw-r--r--src/gui/kernel/qcocoaview_mac_p.h1
-rw-r--r--src/gui/kernel/qkeymapper_mac.cpp15
-rw-r--r--src/gui/kernel/qwidget.cpp2
-rw-r--r--src/gui/math3d/math3d.pri5
-rw-r--r--src/gui/math3d/qfixedpt.cpp711
-rw-r--r--src/gui/math3d/qfixedpt.h551
-rw-r--r--src/gui/math3d/qgenericmatrix.h22
-rw-r--r--src/gui/math3d/qmath3dglobal.h102
-rw-r--r--src/gui/math3d/qmath3dutil.cpp194
-rw-r--r--src/gui/math3d/qmath3dutil_p.h96
-rw-r--r--src/gui/math3d/qmatrix4x4.cpp376
-rw-r--r--src/gui/math3d/qmatrix4x4.h177
-rw-r--r--src/gui/math3d/qquaternion.cpp33
-rw-r--r--src/gui/math3d/qquaternion.h49
-rw-r--r--src/gui/math3d/qvector2d.cpp9
-rw-r--r--src/gui/math3d/qvector2d.h34
-rw-r--r--src/gui/math3d/qvector3d.cpp8
-rw-r--r--src/gui/math3d/qvector3d.h41
-rw-r--r--src/gui/math3d/qvector4d.cpp12
-rw-r--r--src/gui/math3d/qvector4d.h46
-rw-r--r--src/gui/painting/qbezier.cpp24
-rw-r--r--src/gui/painting/qcolor.cpp4
-rw-r--r--src/gui/painting/qmatrix.h6
-rw-r--r--src/gui/painting/qpaintengine_d3d.cpp6
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp24
-rw-r--r--src/gui/painting/qpainter.cpp24
-rw-r--r--src/gui/painting/qpainterpath.cpp8
-rw-r--r--src/gui/painting/qpathclipper.cpp36
-rw-r--r--src/gui/painting/qstroker.cpp12
-rw-r--r--src/gui/painting/qtessellator.cpp2
-rw-r--r--src/gui/painting/qtransform.cpp16
-rw-r--r--src/gui/painting/qtransform.h2
-rw-r--r--src/gui/widgets/qcombobox.cpp37
-rw-r--r--src/gui/widgets/qcombobox_p.h1
40 files changed, 546 insertions, 2195 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index b8ff5b4..e7f9bd3 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -1906,11 +1906,11 @@ void QGraphicsItem::setOpacity(qreal opacity)
newOpacity = qBound<qreal>(0.0, newOpacity, 1.0);
// No change? Done.
- if (qIsFuzzyNull(newOpacity - this->opacity()))
+ if (qFuzzyIsNull(newOpacity - this->opacity()))
return;
// Assign local opacity.
- if (qIsFuzzyNull(newOpacity - 1)) {
+ if (qFuzzyIsNull(newOpacity - 1)) {
// Opaque, unset opacity.
d_ptr->hasOpacity = 0;
d_ptr->unsetExtra(QGraphicsItemPrivate::ExtraOpacity);
@@ -3771,7 +3771,7 @@ void QGraphicsItemPrivate::resolveEffectiveOpacity(qreal parentEffectiveOpacity)
}
// Set this item's resolved opacity.
- if (qIsFuzzyNull(myEffectiveOpacity - 1)) {
+ if (qFuzzyIsNull(myEffectiveOpacity - 1)) {
// Opaque, unset effective opacity.
hasEffectiveOpacity = 0;
unsetExtra(ExtraEffectiveOpacity);
@@ -4091,7 +4091,7 @@ void QGraphicsItem::scroll(qreal dx, qreal dy, const QRectF &rect)
return;
if (d->cacheMode != NoCache) {
QGraphicsItemCache *c;
- bool scrollCache = qFuzzyCompare(dx - int(dx), qreal(0.0)) && qFuzzyCompare(dy - int(dy), qreal(0.0))
+ bool scrollCache = qFuzzyIsNull(dx - int(dx)) && qFuzzyIsNull(dy - int(dy))
&& (c = (QGraphicsItemCache *)qVariantValue<void *>(d_ptr->extra(QGraphicsItemPrivate::ExtraCacheData)))
&& (d->cacheMode == ItemCoordinateCache && !c->fixedSize.isValid());
if (scrollCache) {
@@ -5854,7 +5854,7 @@ static void qt_graphicsItem_highlightSelected(
QGraphicsItem *item, QPainter *painter, const QStyleOptionGraphicsItem *option)
{
const QRectF murect = painter->transform().mapRect(QRectF(0, 0, 1, 1));
- if (qIsFuzzyNull(qMax(murect.width(), murect.height())))
+ if (qFuzzyIsNull(qMax(murect.width(), murect.height())))
return;
const QRectF mbrect = painter->transform().mapRect(item->boundingRect());
diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h
index 77db691..078c543 100644
--- a/src/gui/graphicsview/qgraphicsitem_p.h
+++ b/src/gui/graphicsview/qgraphicsitem_p.h
@@ -269,7 +269,7 @@ public:
void updateCachedClipPathFromSetPosHelper(const QPointF &newPos);
inline bool isFullyTransparent() const
- { return hasEffectiveOpacity && qIsFuzzyNull(q_func()->effectiveOpacity()); }
+ { return hasEffectiveOpacity && qFuzzyIsNull(q_func()->effectiveOpacity()); }
inline bool childrenCombineOpacity() const
{ return allChildrenCombineOpacity || children.isEmpty(); }
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index e885238..bd66c3d 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -4642,7 +4642,7 @@ static void _q_paintItem(QGraphicsItem *item, QPainter *painter,
? proxy->widget()->windowOpacity() : 1.0;
const qreal oldPainterOpacity = painter->opacity();
- if (qIsFuzzyNull(windowOpacity))
+ if (qFuzzyIsNull(windowOpacity))
return;
// Set new painter opacity.
if (windowOpacity < 1.0)
@@ -5282,7 +5282,7 @@ void QGraphicsScene::itemUpdated(QGraphicsItem *item, const QRectF &rect)
// Deliver the actual update.
if (!d->updateAll) {
if (d->views.isEmpty() || ((d->connectedSignals & d->changedSignalMask) && !item->d_ptr->itemIsUntransformable()
- && qIsFuzzyNull(item->boundingRegionGranularity()))) {
+ && qFuzzyIsNull(item->boundingRegionGranularity()))) {
// This block of code is kept for compatibility. Since 4.5, by default
// QGraphicsView does not connect the signal and we use the below
// method of delivering updates.
diff --git a/src/gui/inputmethod/qmacinputcontext_mac.cpp b/src/gui/inputmethod/qmacinputcontext_mac.cpp
index f0e7ea9..86385fa 100644
--- a/src/gui/inputmethod/qmacinputcontext_mac.cpp
+++ b/src/gui/inputmethod/qmacinputcontext_mac.cpp
@@ -45,6 +45,7 @@
#include "qtextformat.h"
#include <qdebug.h>
#include <private/qapplication_p.h>
+#include <private/qkeymapper_p.h>
QT_BEGIN_NAMESPACE
@@ -63,7 +64,8 @@ static QTextFormat qt_mac_compose_format()
}
QMacInputContext::QMacInputContext(QObject *parent)
- : QInputContext(parent), composing(false), recursionGuard(false), textDocument(0)
+ : QInputContext(parent), composing(false), recursionGuard(false), textDocument(0),
+ keydownEvent(0)
{
// createTextDocument();
}
@@ -183,6 +185,16 @@ QMacInputContext::cleanup()
#endif
}
+void QMacInputContext::setLastKeydownEvent(EventRef event)
+{
+ EventRef tmpEvent = keydownEvent;
+ keydownEvent = event;
+ if (keydownEvent)
+ RetainEvent(keydownEvent);
+ if (tmpEvent)
+ ReleaseEvent(tmpEvent);
+}
+
OSStatus
QMacInputContext::globalEventProcessor(EventHandlerCallRef, EventRef event, void *)
{
@@ -335,6 +347,12 @@ QMacInputContext::globalEventProcessor(EventHandlerCallRef, EventRef event, void
GetEventParameter(key_ev, kEventParamKeyMacCharCodes, typeChar, 0, sizeof(chr), 0, &chr);
if(!chr || chr >= 128 || (text.length() > 0 && (text.length() > 1 || text.at(0) != QLatin1Char(chr))))
handled_event = !widget->testAttribute(Qt::WA_InputMethodEnabled);
+ QMacInputContext *context = qobject_cast<QMacInputContext*>(qApp->inputContext());
+ if (context && context->lastKeydownEvent()) {
+ qt_keymapper_private()->translateKeyEvent(widget, 0, context->lastKeydownEvent(),
+ 0, false);
+ context->setLastKeydownEvent(0);
+ }
}
break; }
default:
diff --git a/src/gui/inputmethod/qmacinputcontext_p.h b/src/gui/inputmethod/qmacinputcontext_p.h
index f708040..c3f245a 100644
--- a/src/gui/inputmethod/qmacinputcontext_p.h
+++ b/src/gui/inputmethod/qmacinputcontext_p.h
@@ -78,6 +78,10 @@ public:
static OSStatus globalEventProcessor(EventHandlerCallRef, EventRef, void *);
static void initialize();
static void cleanup();
+
+ EventRef lastKeydownEvent() { return keydownEvent; }
+ void setLastKeydownEvent(EventRef);
+
protected:
void mouseHandler(int pos, QMouseEvent *);
private:
@@ -85,6 +89,7 @@ private:
bool recursionGuard;
TSMDocumentID textDocument;
QString currentText;
+ EventRef keydownEvent;
};
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index 19367d1..2d6f5ad 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -195,6 +195,7 @@ extern "C" {
if (self) {
[self finishInitWithQWidget:widget widgetPrivate:widgetprivate];
}
+ composingText = new QString();
composing = false;
sendKeyEvents = true;
[self setHidden:YES];
@@ -364,6 +365,7 @@ extern "C" {
- (void)dealloc
{
+ delete composingText;
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}
@@ -917,7 +919,7 @@ extern "C" {
- (void) insertText:(id)aString
{
- if (composing) {
+ if ([aString length]) {
// Send the commit string to the widget.
QString commitText;
if ([aString isKindOfClass:[NSAttributedString class]]) {
@@ -931,6 +933,7 @@ extern "C" {
e.setCommitString(commitText);
qt_sendSpontaneousEvent(qwidget, &e);
}
+ composingText->clear();
}
- (void) setMarkedText:(id)aString selectedRange:(NSRange)selRange
@@ -984,12 +987,21 @@ extern "C" {
attrs<<QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat,
0, composingLength, format);
}
+ *composingText = qtText;
QInputMethodEvent e(qtText, attrs);
qt_sendSpontaneousEvent(qwidget, &e);
+ if (!composingLength)
+ composing = false;
}
- (void) unmarkText
{
+ if (composing) {
+ QInputMethodEvent e;
+ e.setCommitString(*composingText);
+ qt_sendSpontaneousEvent(qwidget, &e);
+ }
+ composingText->clear();
composing = false;
}
diff --git a/src/gui/kernel/qcocoaview_mac_p.h b/src/gui/kernel/qcocoaview_mac_p.h
index 9de94d5..ec1281e 100644
--- a/src/gui/kernel/qcocoaview_mac_p.h
+++ b/src/gui/kernel/qcocoaview_mac_p.h
@@ -83,6 +83,7 @@ Q_GUI_EXPORT
bool composing;
int composingLength;
bool sendKeyEvents;
+ QString *composingText;
}
- (id)initWithQWidget:(QWidget *)widget widgetPrivate:(QWidgetPrivate *)widgetprivate;
- (void) finishInitWithQWidget:(QWidget *)widget widgetPrivate:(QWidgetPrivate *)widgetprivate;
diff --git a/src/gui/kernel/qkeymapper_mac.cpp b/src/gui/kernel/qkeymapper_mac.cpp
index 1a0fb08..39abc5e 100644
--- a/src/gui/kernel/qkeymapper_mac.cpp
+++ b/src/gui/kernel/qkeymapper_mac.cpp
@@ -48,6 +48,7 @@
#include <qinputcontext.h>
#include <private/qkeymapper_p.h>
#include <private/qapplication_p.h>
+#include <private/qmacinputcontext_p.h>
QT_BEGIN_NAMESPACE
@@ -480,7 +481,8 @@ static bool translateKeyEventInternal(EventHandlerCallRef er, EventRef keyEvent,
#ifdef QT_MAC_USE_COCOA
if (outHandled) {
qt_mac_eat_unicode_key = false;
- CallNextEventHandler(er, keyEvent);
+ if (er)
+ CallNextEventHandler(er, keyEvent);
*outHandled = qt_mac_eat_unicode_key;
}
#endif
@@ -692,8 +694,14 @@ bool QKeyMapperPrivate::translateKeyEvent(QWidget *widget, EventHandlerCallRef e
return true;
}
- if (qApp->inputContext() && qApp->inputContext()->isComposing())
+ if (qApp->inputContext() && qApp->inputContext()->isComposing()) {
+ if (ekind == kEventRawKeyDown) {
+ QMacInputContext *context = qobject_cast<QMacInputContext*>(qApp->inputContext());
+ if (context)
+ context->setLastKeydownEvent(event);
+ }
return false;
+ }
//get modifiers
Qt::KeyboardModifiers modifiers;
int qtKey;
@@ -721,7 +729,8 @@ bool QKeyMapperPrivate::translateKeyEvent(QWidget *widget, EventHandlerCallRef e
//is it of use to text services? If so we won't bother
//with a QKeyEvent.
qt_mac_eat_unicode_key = false;
- CallNextEventHandler(er, event);
+ if (er)
+ CallNextEventHandler(er, event);
extern bool qt_mac_menubar_is_open();
if (qt_mac_eat_unicode_key || qt_mac_menubar_is_open()) {
return true;
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 20b79ce..3e25ffc 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -4780,7 +4780,7 @@ void QWidget::render(QPainter *painter, const QPoint &targetOffset,
}
const qreal opacity = painter->opacity();
- if (qFuzzyCompare(opacity + 1, qreal(1.0)))
+ if (qFuzzyIsNull(opacity))
return; // Fully transparent.
Q_D(QWidget);
diff --git a/src/gui/math3d/math3d.pri b/src/gui/math3d/math3d.pri
index 581adbd..e4dd53a 100644
--- a/src/gui/math3d/math3d.pri
+++ b/src/gui/math3d/math3d.pri
@@ -1,8 +1,5 @@
HEADERS += \
- math3d/qfixedpt.h \
math3d/qgenericmatrix.h \
- math3d/qmath3dglobal.h \
- math3d/qmath3dutil_p.h \
math3d/qmatrix4x4.h \
math3d/qquaternion.h \
math3d/qvector2d.h \
@@ -10,9 +7,7 @@ HEADERS += \
math3d/qvector4d.h
SOURCES += \
- math3d/qfixedpt.cpp \
math3d/qgenericmatrix.cpp \
- math3d/qmath3dutil.cpp \
math3d/qmatrix4x4.cpp \
math3d/qquaternion.cpp \
math3d/qvector2d.cpp \
diff --git a/src/gui/math3d/qfixedpt.cpp b/src/gui/math3d/qfixedpt.cpp
deleted file mode 100644
index 93f2150..0000000
--- a/src/gui/math3d/qfixedpt.cpp
+++ /dev/null
@@ -1,711 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the $MODULE$ of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qfixedpt.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \internal
- Returns the fixed-point square root of \a value.
-*/
-qint64 qt_math3d_fixed_sqrt(qint64 value)
-{
- qint64 result = 0;
- qint64 bit = ((qint64)1) << 62;
- while (bit > value)
- bit >>= 2;
- while (bit != 0) {
- if (value >= (result + bit)) {
- value -= result + bit;
- result += (bit << 1);
- }
- result >>= 1;
- bit >>= 2;
- }
- return result;
-}
-
-/*!
- \class QFixedPt
- \brief The QFixedPt class represents fixed-point numbers within a 32-bit integer with a configurable precision.
-
- The template parameter is the number of bits of precision after
- the decimal point. For example, QFixedPt<5> indicates that there
- are 27 bits before the decimal point, and 5 bits of precision after
- the decimal point.
-*/
-
-/*!
- \fn QFixedPt::QFixedPt()
-
- Constructs a default fixed-point number. The initial value
- is undefined.
-*/
-
-/*!
- \fn QFixedPt::QFixedPt(int value)
-
- Constructs a fixed-point number from the integer \a value.
-*/
-
-/*!
- \fn QFixedPt::QFixedPt(qreal value)
-
- Constructs a fixed-point number from the floating-point \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator=(int value)
-
- Assigns the integer \a value to this fixed-point variable.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator=(qreal value)
-
- Assigns the floating-point \a value to this fixed-point variable.
-*/
-
-/*!
- \fn int QFixedPt::bits() const
-
- Returns the raw bits that represent the fixed-point value of this object.
-
- \sa setBits()
-*/
-
-/*!
- \fn void QFixedPt::setBits(int value)
-
- Sets the raw bits that represent the fixed-point value of
- this object to \a value.
-
- \sa bits()
-*/
-
-#if !defined(QT_NO_MEMBER_TEMPLATES) || defined(Q_QDOC)
-
-/*!
- \fn QFixedPt<Prec> QFixedPt::toPrecision() const
-
- Returns this fixed-point number, converted to the new fixed-point
- precision Prec.
-
- \sa qFixedPtToPrecision()
-*/
-
-#endif
-
-/*!
- \fn QFixedPt<Prec> qFixedPtToPrecision(const QFixedPt<PrecBits>& value)
-
- Returns the fixed-point number \a value, converted to the new fixed-point
- precision Prec.
-
- \sa QFixedPt::toPrecision()
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator+=(const QFixedPt<PrecBits>& value)
-
- Adds \a value to this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator+=(int value)
-
- Adds an integer \a value to this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator+=(qreal value)
-
- Adds a floating-point \a value to this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator-=(const QFixedPt<PrecBits>& value)
-
- Subtracts \a value from this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator-=(int value)
-
- Subtracts an integer \a value from this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator-=(qreal value)
-
- Subtracts a floating-point \a value from this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator*=(const QFixedPt<PrecBits>& value)
-
- Multiplies this fixed-point number by \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator*=(int value)
-
- Multiplies this fixed-point number by an integer \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator*=(qreal value)
-
- Multiplies this fixed-point number by a floating-point \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator/=(const QFixedPt<PrecBits>& value)
-
- Divides this fixed-point number by \a value. Division by zero
- will result in zero.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator/=(int value)
-
- Divides this fixed-point number by an integer \a value. Division
- by zero will result in zero.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator/=(qreal value)
-
- Divides this fixed-point number by a floating-point \a value. Division
- by zero will result in zero.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator<<=(int value)
-
- Shifts this fixed-point number left by \a value bits.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator>>=(int value)
-
- Shifts this fixed-point number right by \a value bits.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator<<(int value) const
-
- Returns the result of shifting this fixed-point number
- left by \a value bits.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator>>(int value) const
-
- Returns the result of shifting this fixed-point number
- right by \a value bits.
-*/
-
-/*!
- \fn bool QFixedPt::operator==(const QFixedPt<PrecBits>& value) const
-
- Returns true if this fixed-point number is equal to \a value;
- false otherwise.
-*/
-
-/*!
- \fn bool operator==(const QFixedPt<PrecBits>& v1, int v2)
- \relates QFixedPt
-
- Returns true if \a v1 is equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator==(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator==(const QFixedPt<PrecBits>& v1, qreal v2)
- \relates QFixedPt
-
- Returns true if \a v1 is equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator==(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool QFixedPt::operator!=(const QFixedPt<PrecBits>& value) const
-
- Returns true if this fixed-point number is not equal to \a value;
- false otherwise.
-*/
-
-/*!
- \fn bool operator!=(const QFixedPt<PrecBits>& v1, int v2)
- \relates QFixedPt
-
- Returns true if \a v1 is not equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator!=(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is not equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator!=(const QFixedPt<PrecBits>& v1, qreal v2)
- \relates QFixedPt
-
- Returns true if \a v1 is not equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator!=(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is not equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool QFixedPt::operator<=(const QFixedPt<PrecBits>& value) const
-
- Returns true if this fixed-point number is less than or equal to
- \a value; false otherwise.
-*/
-
-/*!
- \fn bool operator<=(const QFixedPt<PrecBits>& v1, int v2)
- \relates QFixedPt
-
- Returns true if \a v1 is less than or equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator<=(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is less than or equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator<=(const QFixedPt<PrecBits>& v1, qreal v2)
- \relates QFixedPt
-
- Returns true if \a v1 is less than or equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator<=(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is less than or equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool QFixedPt::operator<(const QFixedPt<PrecBits>& value) const
-
- Returns true if this fixed-point number is less than \a value;
- false otherwise.
-*/
-
-/*!
- \fn bool operator<(const QFixedPt<PrecBits>& v1, int v2)
- \relates QFixedPt
-
- Returns true if \a v1 is less than \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator<(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is less than \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator<(const QFixedPt<PrecBits>& v1, qreal v2)
- \relates QFixedPt
-
- Returns true if \a v1 is less than \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator<(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is less than \a v2; false otherwise.
-*/
-
-/*!
- \fn bool QFixedPt::operator>=(const QFixedPt<PrecBits>& value) const
-
- Returns true if this fixed-point number is greater than or equal to
- \a value; false otherwise.
-*/
-
-/*!
- \fn bool operator>=(const QFixedPt<PrecBits>& v1, int v2)
- \relates QFixedPt
-
- Returns true if \a v1 is greater than or equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator>=(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is greater than or equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator>=(const QFixedPt<PrecBits>& v1, qreal v2)
- \relates QFixedPt
-
- Returns true if \a v1 is greater than or equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator>=(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is greater than or equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool QFixedPt::operator>(const QFixedPt<PrecBits>& value) const
-
- Returns true if this fixed-point number is greater than \a value;
- false otherwise.
-*/
-
-/*!
- \fn bool operator>(const QFixedPt<PrecBits>& v1, int v2)
- \relates QFixedPt
-
- Returns true if \a v1 is greater than \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator>(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is greater than \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator>(const QFixedPt<PrecBits>& v1, qreal v2)
- \relates QFixedPt
-
- Returns true if \a v1 is greater than \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator>(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is greater than \a v2; false otherwise.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator+(const QFixedPt<PrecBits>& value) const
-
- Returns the result of adding this fixed-point number and \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator+(int value) const
-
- Returns the result of adding this fixed-point number and \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator+(qreal value) const
-
- Returns the result of adding this fixed-point number and \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> operator+(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns the result of adding \a v1 and \a v2.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> operator+(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns the result of adding \a v1 and \a v2.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator-(const QFixedPt<PrecBits>& value) const
-
- Returns the result of subtracting \a value from this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator-(int value) const
-
- Returns the result of subtracting \a value from this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator-(qreal value) const
-
- Returns the result of subtracting \a value from this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> operator-(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns the result of subtracting \a v2 from \a v1.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> operator-(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns the result of subtracting \a v2 from \a v1.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator*(const QFixedPt<PrecBits>& value) const
-
- Returns the result of multiplying this fixed-point number by \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator*(int value) const
-
- Returns the result of multiplying this fixed-point number by \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator*(qreal value) const
-
- Returns the result of multiplying this fixed-point number by \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> operator*(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns the result of multiplying \a v1 by \a v2.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> operator*(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns the result of multiplying \a v1 by \a v2.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator/(const QFixedPt<PrecBits>& value) const
-
- Returns the result of dividing this fixed-point number by \a value.
- Division by zero will result in zero.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator/(int value) const
-
- Returns the result of dividing this fixed-point number by \a value.
- Division by zero will result in zero.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator/(qreal value) const
-
- Returns the result of dividing this fixed-point number by \a value.
- Division by zero will result in zero.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> operator/(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns the result of dividing \a v1 by \a v2. Division by zero will
- result in zero.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> operator/(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns the result of dividing \a v1 by \a v2. Division by zero will
- result in zero.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator-() const
-
- Returns the negation of this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::sqrt() const
-
- Returns the square root of this fixed-point number.
-
- \sa sqrtF()
-*/
-
-/*!
- \fn qreal QFixedPt::sqrtF() const
-
- Return the square root of this fixed-point number as a
- floating-point value.
-
- \sa sqrt()
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::round() const
-
- Returns this fixed-point number, rounded to the nearest integer.
-
- \sa floor(), ceil(), truncate()
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::floor() const;
-
- Returns the largest integer that is less than or equal to
- this fixed-point number.
-
- \sa round(), ceil(), truncate()
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::ceil() const
-
- Returns the smallest integer that is greater than or equal to
- this fixed-point number.
-
- \sa round(), floor(), truncate()
-*/
-
-/*!
- \fn int QFixedPt::truncate() const
-
- Returns this fixed-point number with the bits after the
- decimal point truncated.
-
- \sa round(), floor(), ceil()
-*/
-
-/*!
- \fn int QFixedPt::toInt() const
-
- Returns this fixed-point number, rounded to the nearest integer.
-
- \sa toReal()
-*/
-
-/*!
- \fn qreal QFixedPt::toReal() const
-
- Returns this fixed-point number as a floating-point value.
-
- \sa toInt()
-*/
-
-/*!
- \fn int qCeil(const QFixedPt<PrecBits>& value)
- \relates QFixedPt
-
- Returns the smallest integer that is greater than or equal to
- \a value.
-
- \sa qFloor(), qRound(), QFixedPt::ceil()
-*/
-
-/*!
- \fn int qFloor(const QFixedPt<PrecBits>& value)
- \relates QFixedPt
-
- Returns the largest integer that is less than or equal to
- \a value.
-
- \sa qCeil(), qRound(), QFixedPt::floor()
-*/
-
-/*!
- \fn int qRound(const QFixedPt<PrecBits>& value)
- \relates QFixedPt
-
- Returns \a value, rounded to the nearest integer.
-
- \sa qCeil(), qFloor(), QFixedPt::round()
-*/
-
-/*!
- \fn bool qFuzzyCompare(const QFixedPt<PrecBits>& v1, const QFixedPt<PrecBits>& v2, int compareBits)
- \relates QFixedPt
-
- Returns true if \a v1 is almost equal to \a v2; false otherwise.
- The \a compareBits parameter specifies the number of bits of precision
- that should be considered relevant when performing the comparison.
- By default, \a compareBits is PrecBits / 4.
-*/
-
-/*!
- \fn bool qIsNull(const QFixedPt<PrecBits>& v)
- \relates QFixedPt
-
- Returns true if \a v is zero; false otherwise.
-*/
-
-QT_END_NAMESPACE
diff --git a/src/gui/math3d/qfixedpt.h b/src/gui/math3d/qfixedpt.h
deleted file mode 100644
index 142f62f..0000000
--- a/src/gui/math3d/qfixedpt.h
+++ /dev/null
@@ -1,551 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the $MODULE$ of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QFIXEDPT_H
-#define QFIXEDPT_H
-
-#include <QtCore/qglobal.h>
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-Q_GUI_EXPORT qint64 qt_math3d_fixed_sqrt(qint64 value);
-
-// Should be called QFixed or QFixedPoint, but both of those
-// are already in use in src/gui/painting/qfixed_p.h.
-template <int PrecBits>
-class QFixedPt
-{
-public:
- inline QFixedPt() {} // Deliberately not initialized - don't change this.
- inline QFixedPt(int value) : val(value << PrecBits) {}
- inline QFixedPt(qreal value) : val(int(value * (1 << PrecBits))) {}
-
- inline QFixedPt<PrecBits>& operator=(int value)
- { val = value << PrecBits; return *this; }
- inline QFixedPt<PrecBits>& operator=(qreal value)
- { val = int(value * (1 << PrecBits)); return *this; }
-
- inline int bits() const { return val; }
- inline void setBits(int value) { val = value; }
-
-#if !defined(QT_NO_MEMBER_TEMPLATES) || defined(Q_QDOC)
- template <int Prec>
- inline QFixedPt<Prec> toPrecision() const
- {
- QFixedPt<Prec> result;
- if (Prec < PrecBits)
- result.setBits(shiftRight(val, (PrecBits - Prec)));
- else
- result.setBits(shiftLeft(val, (Prec - PrecBits)));
- return result;
- }
-#endif
-
- inline QFixedPt<PrecBits>& operator+=(const QFixedPt<PrecBits>& value)
- { val += value.val; return *this; }
- inline QFixedPt<PrecBits>& operator+=(int value)
- { val += (value << PrecBits); return *this; }
- inline QFixedPt<PrecBits>& operator+=(qreal value)
- { val += int(value * (1 << PrecBits)); return *this; }
-
- inline QFixedPt<PrecBits>& operator-=(const QFixedPt<PrecBits>& value)
- { val -= value.val; return *this; }
- inline QFixedPt<PrecBits>& operator-=(int value)
- { val -= (value << PrecBits); return *this; }
- inline QFixedPt<PrecBits>& operator-=(qreal value)
- { val -= int(value * (1 << PrecBits)); return *this; }
-
- inline QFixedPt<PrecBits>& operator*=(const QFixedPt<PrecBits>& value)
- { val = mul(val, value.val); return *this; }
- inline QFixedPt<PrecBits>& operator*=(int value)
- { val = mul(val, (value << PrecBits)); return *this; }
- inline QFixedPt<PrecBits>& operator*=(qreal value)
- { val = mul(val, int(value * (1 << PrecBits))); return *this; }
-
- inline QFixedPt<PrecBits>& operator/=(const QFixedPt<PrecBits>& value)
- { val = div(val, value.val); return *this; }
- inline QFixedPt<PrecBits>& operator/=(int value)
- { val = div(val, (value << PrecBits)); return *this; }
- inline QFixedPt<PrecBits>& operator/=(qreal value)
- { val = div(val, int(value * (1 << PrecBits))); return *this; }
-
- inline QFixedPt<PrecBits>& operator<<=(int value)
- { val <<= value; return *this; }
- inline QFixedPt<PrecBits>& operator>>=(int value)
- { val >>= value; return *this; }
-
- inline QFixedPt<PrecBits> operator<<(int value) const
- { QFixedPt<PrecBits> result; result.val = val << value; return result; }
- inline QFixedPt<PrecBits> operator>>(int value) const
- { QFixedPt<PrecBits> result; result.val = val >> value; return result; }
-
- inline bool operator==(const QFixedPt<PrecBits>& value) const
- { return val == value.val; }
- inline bool operator!=(const QFixedPt<PrecBits>& value) const
- { return val != value.val; }
- inline bool operator<=(const QFixedPt<PrecBits>& value) const
- { return val <= value.val; }
- inline bool operator<(const QFixedPt<PrecBits>& value) const
- { return val < value.val; }
- inline bool operator>=(const QFixedPt<PrecBits>& value) const
- { return val >= value.val; }
- inline bool operator>(const QFixedPt<PrecBits>& value) const
- { return val > value.val; }
-
- inline QFixedPt<PrecBits> operator+(const QFixedPt<PrecBits>& value) const
- { QFixedPt<PrecBits> result;
- result.val = val + value.val; return result; }
- inline QFixedPt<PrecBits> operator+(int value) const
- { QFixedPt<PrecBits> result;
- result.val = val + (value << PrecBits); return result; }
- inline QFixedPt<PrecBits> operator+(qreal value) const
- { QFixedPt<PrecBits> result;
- result.val = val + int(value * (1 << PrecBits)); return result; }
-
- inline QFixedPt<PrecBits> operator-(const QFixedPt<PrecBits>& value) const
- { QFixedPt<PrecBits> result;
- result.val = val - value.val; return result; }
- inline QFixedPt<PrecBits> operator-(int value) const
- { QFixedPt<PrecBits> result;
- result.val = val - (value << PrecBits); return result; }
- inline QFixedPt<PrecBits> operator-(qreal value) const
- { QFixedPt<PrecBits> result;
- result.val = val - int(value * (1 << PrecBits)); return result; }
-
- inline QFixedPt<PrecBits> operator*(const QFixedPt<PrecBits>& value) const
- { QFixedPt<PrecBits> result;
- result.val = mul(val, value.val); return result; }
- inline QFixedPt<PrecBits> operator*(int value) const
- { QFixedPt<PrecBits> result;
- result.val = mul(val, (value << PrecBits)); return result; }
- inline QFixedPt<PrecBits> operator*(qreal value) const
- { QFixedPt<PrecBits> result;
- result.val = mul(val, int(value * (1 << PrecBits))); return result; }
-
- inline QFixedPt<PrecBits> operator/(const QFixedPt<PrecBits>& value) const
- { QFixedPt<PrecBits> result;
- result.val = div(val, value.val); return result; }
- inline QFixedPt<PrecBits> operator/(int value) const
- { QFixedPt<PrecBits> result;
- result.val = div(val, (value << PrecBits)); return result; }
- inline QFixedPt<PrecBits> operator/(qreal value) const
- { QFixedPt<PrecBits> result;
- result.val = div(val, int(value * (1 << PrecBits))); return result; }
-
- inline QFixedPt<PrecBits> operator-() const
- { QFixedPt<PrecBits> result; result.val = -val; return result; }
-
- inline QFixedPt<PrecBits> sqrt() const;
- inline qreal sqrtF() const;
- inline QFixedPt<PrecBits> round() const;
- inline QFixedPt<PrecBits> floor() const;
- inline QFixedPt<PrecBits> ceil() const;
- inline int truncate() const { return val >> PrecBits; }
-
- inline int toInt() const { return (val + (1 << (PrecBits - 1))) >> PrecBits; }
- inline qreal toReal() const { return qreal(val) / qreal(1 << PrecBits); }
-
-#if !defined(Q_NO_TEMPLATE_FRIENDS)
- template <int Prec>
- friend QFixedPt<Prec> operator/(int v1, const QFixedPt<Prec>& v2);
- template <int Prec>
- friend QFixedPt<Prec> operator/(qreal v1, const QFixedPt<Prec>& v2);
-
-private:
-#endif
- int val;
-
- inline static int mul(int v1, int v2)
- {
- return int((qint64(v1) * qint64(v2)) >> PrecBits);
- }
-
- inline static int div(int v1, int v2)
- {
- if (v2)
- return int((qint64(v1) << PrecBits) / qint64(v2));
- else
- return 0;
- }
-
- // These are used by toPrecision() to avoid a silly gcc compiler warning
- // related to negative shift values that will never actually be used.
- inline static int shiftRight(int val, int shift)
- {
- return val >> shift;
- }
- inline static int shiftLeft(int val, int shift)
- {
- return val << shift;
- }
-
-#if !defined(Q_NO_TEMPLATE_FRIENDS)
- template <int Prec, int Prec2>
- friend QFixedPt<Prec> qFixedPtToPrecision(const QFixedPt<Prec2>& value);
-#endif
-};
-
-template <int PrecBits>
-inline bool operator==(const QFixedPt<PrecBits>& v1, int v2)
-{
- return v1.bits() == (v2 << PrecBits);
-}
-
-template <int PrecBits>
-inline bool operator==(int v1, const QFixedPt<PrecBits>& v2)
-{
- return (v1 << PrecBits) == v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator==(const QFixedPt<PrecBits>& v1, qreal v2)
-{
- return v1.bits() == int(v2 * (1 << PrecBits));
-}
-
-template <int PrecBits>
-inline bool operator==(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return int(v1 * (1 << PrecBits)) == v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator!=(const QFixedPt<PrecBits>& v1, int v2)
-{
- return v1.bits() != (v2 << PrecBits);
-}
-
-template <int PrecBits>
-inline bool operator!=(int v1, const QFixedPt<PrecBits>& v2)
-{
- return (v1 << PrecBits) != v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator!=(const QFixedPt<PrecBits>& v1, qreal v2)
-{
- return v1.bits() != int(v2 * (1 << PrecBits));
-}
-
-template <int PrecBits>
-inline bool operator!=(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return int(v1 * (1 << PrecBits)) != v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator<=(const QFixedPt<PrecBits>& v1, int v2)
-{
- return v1.bits() <= (v2 << PrecBits);
-}
-
-template <int PrecBits>
-inline bool operator<=(int v1, const QFixedPt<PrecBits>& v2)
-{
- return (v1 << PrecBits) <= v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator<=(const QFixedPt<PrecBits>& v1, qreal v2)
-{
- return v1.bits() <= int(v2 * (1 << PrecBits));
-}
-
-template <int PrecBits>
-inline bool operator<=(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return int(v1 * (1 << PrecBits)) <= v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator<(const QFixedPt<PrecBits>& v1, int v2)
-{
- return v1.bits() < (v2 << PrecBits);
-}
-
-template <int PrecBits>
-inline bool operator<(int v1, const QFixedPt<PrecBits>& v2)
-{
- return (v1 << PrecBits) < v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator<(const QFixedPt<PrecBits>& v1, qreal v2)
-{
- return v1.bits() < int(v2 * (1 << PrecBits));
-}
-
-template <int PrecBits>
-inline bool operator<(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return int(v1 * (1 << PrecBits)) < v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator>=(const QFixedPt<PrecBits>& v1, int v2)
-{
- return v1.bits() >= (v2 << PrecBits);
-}
-
-template <int PrecBits>
-inline bool operator>=(int v1, const QFixedPt<PrecBits>& v2)
-{
- return (v1 << PrecBits) >= v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator>=(const QFixedPt<PrecBits>& v1, qreal v2)
-{
- return v1.bits() >= int(v2 * (1 << PrecBits));
-}
-
-template <int PrecBits>
-inline bool operator>=(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return int(v1 * (1 << PrecBits)) >= v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator>(const QFixedPt<PrecBits>& v1, int v2)
-{
- return v1.bits() > (v2 << PrecBits);
-}
-
-template <int PrecBits>
-inline bool operator>(int v1, const QFixedPt<PrecBits>& v2)
-{
- return (v1 << PrecBits) > v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator>(const QFixedPt<PrecBits>& v1, qreal v2)
-{
- return v1.bits() > int(v2 * (1 << PrecBits));
-}
-
-template <int PrecBits>
-inline bool operator>(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return int(v1 * (1 << PrecBits)) > v2.bits();
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> operator+(int v1, const QFixedPt<PrecBits>& v2)
-{
- return v2 + v1;
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> operator+(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return v2 + v1;
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> operator-(int v1, const QFixedPt<PrecBits>& v2)
-{
- return -(v2 - v1);
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> operator-(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return -(v2 - v1);
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> operator*(int v1, const QFixedPt<PrecBits>& v2)
-{
- return v2 * v1;
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> operator*(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return v2 * v1;
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> operator/(int v1, const QFixedPt<PrecBits>& v2)
-{
- QFixedPt<PrecBits> result;
- result.val = QFixedPt<PrecBits>::div(v1 << PrecBits, v2.val);
- return result;
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> operator/(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- QFixedPt<PrecBits> result;
- result.val = QFixedPt<PrecBits>::div(int(v1 * (1 << PrecBits)), v2.val);
- return result;
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> QFixedPt<PrecBits>::sqrt() const
-{
- QFixedPt<PrecBits> result;
- result.val = int(qt_math3d_fixed_sqrt
- (qint64(val) << (PrecBits * 2)) >> (PrecBits / 2));
- return result;
-}
-
-template <int PrecBits>
-inline qreal QFixedPt<PrecBits>::sqrtF() const
-{
- return qt_math3d_fixed_sqrt
- (qint64(val) << (PrecBits * 2)) / (qreal)(1 << (PrecBits + (PrecBits / 2)));
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> QFixedPt<PrecBits>::round() const
-{
- QFixedPt<PrecBits> result;
- result.val = (val + (1 << (PrecBits - 1))) & ~((1 << PrecBits) - 1);
- return result;
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> QFixedPt<PrecBits>::floor() const
-{
- QFixedPt<PrecBits> result;
- result.val = val & ~((1 << PrecBits) - 1);
- return result;
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> QFixedPt<PrecBits>::ceil() const
-{
- QFixedPt<PrecBits> result;
- result.val = (val + (1 << PrecBits) - 1) & ~((1 << PrecBits) - 1);
- return result;
-}
-
-template <int PrecBits>
-inline int qCeil(const QFixedPt<PrecBits>& value)
-{
- return value.ceil().bits() >> PrecBits;
-}
-
-template <int PrecBits>
-inline int qFloor(const QFixedPt<PrecBits>& value)
-{
- return value.floor().bits() >> PrecBits;
-}
-
-template <int PrecBits>
-inline int qRound(const QFixedPt<PrecBits>& value)
-{
- return value.round().bits() >> PrecBits;
-}
-
-template <int PrecBits>
-inline bool qFuzzyCompare(const QFixedPt<PrecBits>& v1, const QFixedPt<PrecBits>& v2, int compareBits = (PrecBits / 4))
-{
- return ((v1.bits() ^ v2.bits()) & ~((1 << compareBits) - 1)) == 0;
-}
-
-template <int PrecBits>
-inline bool qIsNull(const QFixedPt<PrecBits>& v)
-{
- return v.bits() == 0;
-}
-
-template <int Prec, int PrecBits>
-QFixedPt<Prec> qFixedPtToPrecision(const QFixedPt<PrecBits>& value)
-{
- QFixedPt<Prec> result;
- if (Prec < PrecBits)
- result.setBits(QFixedPt<PrecBits>::shiftRight(value.bits(), (PrecBits - Prec)));
- else
- result.setBits(QFixedPt<PrecBits>::shiftLeft(value.bits(), (Prec - PrecBits)));
- return result;
-}
-
-template <int PrecBits>
-inline QDebug &operator<<(QDebug &dbg, const QFixedPt<PrecBits> &f)
-{
- return dbg << f.toReal();
-}
-
-Q_DECLARE_TYPEINFO(QFixedPt<0>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<1>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<2>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<3>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<4>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<5>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<6>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<7>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<8>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<9>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<10>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<11>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<12>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<13>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<14>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<15>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<16>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<17>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<18>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<19>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<20>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<21>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<22>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<23>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<24>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<25>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<26>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<27>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<28>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<29>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<30>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<31>, Q_PRIMITIVE_TYPE);
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/gui/math3d/qgenericmatrix.h b/src/gui/math3d/qgenericmatrix.h
index dbeaaf3..d0b22de 100644
--- a/src/gui/math3d/qgenericmatrix.h
+++ b/src/gui/math3d/qgenericmatrix.h
@@ -42,8 +42,8 @@
#ifndef QGENERICMATRIX_H
#define QGENERICMATRIX_H
-#include <QtGui/qmath3dglobal.h>
#include <QtCore/qmetatype.h>
+#include <QtCore/qdebug.h>
QT_BEGIN_HEADER
@@ -134,7 +134,7 @@ template <int N, int M, typename T, typename InnerT>
Q_INLINE_TEMPLATE T QGenericMatrix<N, M, T, InnerT>::operator()(int row, int column) const
{
Q_ASSERT(row >= 0 && row < M && column >= 0 && column < N);
- return qt_math3d_convert<T, InnerT>(m[column][row]);
+ return T(m[column][row]);
}
template <int N, int M, typename T, typename InnerT>
@@ -323,18 +323,18 @@ Q_OUTOFLINE_TEMPLATE void QGenericMatrix<N, M, T, InnerT>::toValueArray(T *value
{
for (int col = 0; col < N; ++col)
for (int row = 0; row < M; ++row)
- values[row * N + col] = qt_math3d_convert<T, InnerT>(m[col][row]);
+ values[row * N + col] = T(m[col][row]);
}
// Define aliases for the useful variants of QGenericMatrix.
-typedef QGenericMatrix<2, 2, qreal, qrealinner> QMatrix2x2;
-typedef QGenericMatrix<2, 3, qreal, qrealinner> QMatrix2x3;
-typedef QGenericMatrix<2, 4, qreal, qrealinner> QMatrix2x4;
-typedef QGenericMatrix<3, 2, qreal, qrealinner> QMatrix3x2;
-typedef QGenericMatrix<3, 3, qreal, qrealinner> QMatrix3x3;
-typedef QGenericMatrix<3, 4, qreal, qrealinner> QMatrix3x4;
-typedef QGenericMatrix<4, 2, qreal, qrealinner> QMatrix4x2;
-typedef QGenericMatrix<4, 3, qreal, qrealinner> QMatrix4x3;
+typedef QGenericMatrix<2, 2, qreal, float> QMatrix2x2;
+typedef QGenericMatrix<2, 3, qreal, float> QMatrix2x3;
+typedef QGenericMatrix<2, 4, qreal, float> QMatrix2x4;
+typedef QGenericMatrix<3, 2, qreal, float> QMatrix3x2;
+typedef QGenericMatrix<3, 3, qreal, float> QMatrix3x3;
+typedef QGenericMatrix<3, 4, qreal, float> QMatrix3x4;
+typedef QGenericMatrix<4, 2, qreal, float> QMatrix4x2;
+typedef QGenericMatrix<4, 3, qreal, float> QMatrix4x3;
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/gui/math3d/qmath3dglobal.h b/src/gui/math3d/qmath3dglobal.h
deleted file mode 100644
index c2f7184..0000000
--- a/src/gui/math3d/qmath3dglobal.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the $MODULE$ of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMATH3DGLOBAL_H
-#define QMATH3DGLOBAL_H
-
-#include <QtCore/qglobal.h>
-#include <QtGui/qfixedpt.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-// Detect the presence of a fixed-point OpenGL implementation.
-#if defined(QT_OPENGL_ES_1_CL) || defined(QT_NO_GL_FLOAT)
-#ifndef QT_GL_FIXED_PREFERRED
-#define QT_GL_FIXED_PREFERRED 1
-#endif
-#endif
-
-// QT_GL_FIXED_PREFERRED indicates that fixed-point should be
-// preferred over floating-point for operations requiring high performance.
-//
-// qreal is the floating-point type that should be used in
-// user-visible functions. qrealinner is used internally where
-// values may be stored as either floating-point or fixed-point.
-// qrealinner will typically be the same size as GLfloat or GLfixed.
-#if defined(QT_GL_FIXED_PREFERRED)
-typedef QFixedPt<16> qrealinner;
-#else
-typedef float qrealinner;
-#endif
-
-// Explicit conversion operator, primarily for converting from
-// fixed point back to floating-point. This is safer than
-// declaring conversion operators in the QFixedPt class.
-template <typename T1, typename T2>
-T1 qt_math3d_convert(T2 v)
-{
- return T1(v);
-}
-template <>
-inline float qt_math3d_convert< float, QFixedPt<16> >(QFixedPt<16> v)
-{
- return float(v.toReal());
-}
-template <>
-inline double qt_math3d_convert< double, QFixedPt<16> >(QFixedPt<16> v)
-{
- return double(v.toReal());
-}
-template <>
-inline int qt_math3d_convert< int, QFixedPt<16> >(QFixedPt<16> v)
-{
- return v.toInt();
-}
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/gui/math3d/qmath3dutil.cpp b/src/gui/math3d/qmath3dutil.cpp
deleted file mode 100644
index ad84162..0000000
--- a/src/gui/math3d/qmath3dutil.cpp
+++ /dev/null
@@ -1,194 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the $MODULE$ of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmath3dutil_p.h"
-
-QT_BEGIN_NAMESPACE
-
-#ifdef QT_GL_FIXED_PREFERRED
-
-// The table that follows was automatically generated by the following code:
-//
-//#include <math.h>
-//#include <stdio.h>
-//
-//int main()
-//{
-// double angle;
-// int count = 0;
-// for (angle = 0.0; angle < 360.0; angle += 1.0) {
-// if ((count % 4) == 0)
-// printf(" ");
-// printf(" qf2vt(%f)", sin(angle * M_PI / 180.0));
-// ++count;
-// if (count != 360)
-// printf(",");
-// if ((count % 4) == 0)
-// printf("\n");
-// }
-// return 0;
-//}
-
-#define qf2vt(x) (int((x) * 65536.0))
-
-static int const sinTable[360] = {
- qf2vt(0.000000), qf2vt(0.017452), qf2vt(0.034899), qf2vt(0.052336),
- qf2vt(0.069756), qf2vt(0.087156), qf2vt(0.104528), qf2vt(0.121869),
- qf2vt(0.139173), qf2vt(0.156434), qf2vt(0.173648), qf2vt(0.190809),
- qf2vt(0.207912), qf2vt(0.224951), qf2vt(0.241922), qf2vt(0.258819),
- qf2vt(0.275637), qf2vt(0.292372), qf2vt(0.309017), qf2vt(0.325568),
- qf2vt(0.342020), qf2vt(0.358368), qf2vt(0.374607), qf2vt(0.390731),
- qf2vt(0.406737), qf2vt(0.422618), qf2vt(0.438371), qf2vt(0.453990),
- qf2vt(0.469472), qf2vt(0.484810), qf2vt(0.500000), qf2vt(0.515038),
- qf2vt(0.529919), qf2vt(0.544639), qf2vt(0.559193), qf2vt(0.573576),
- qf2vt(0.587785), qf2vt(0.601815), qf2vt(0.615661), qf2vt(0.629320),
- qf2vt(0.642788), qf2vt(0.656059), qf2vt(0.669131), qf2vt(0.681998),
- qf2vt(0.694658), qf2vt(0.707107), qf2vt(0.719340), qf2vt(0.731354),
- qf2vt(0.743145), qf2vt(0.754710), qf2vt(0.766044), qf2vt(0.777146),
- qf2vt(0.788011), qf2vt(0.798636), qf2vt(0.809017), qf2vt(0.819152),
- qf2vt(0.829038), qf2vt(0.838671), qf2vt(0.848048), qf2vt(0.857167),
- qf2vt(0.866025), qf2vt(0.874620), qf2vt(0.882948), qf2vt(0.891007),
- qf2vt(0.898794), qf2vt(0.906308), qf2vt(0.913545), qf2vt(0.920505),
- qf2vt(0.927184), qf2vt(0.933580), qf2vt(0.939693), qf2vt(0.945519),
- qf2vt(0.951057), qf2vt(0.956305), qf2vt(0.961262), qf2vt(0.965926),
- qf2vt(0.970296), qf2vt(0.974370), qf2vt(0.978148), qf2vt(0.981627),
- qf2vt(0.984808), qf2vt(0.987688), qf2vt(0.990268), qf2vt(0.992546),
- qf2vt(0.994522), qf2vt(0.996195), qf2vt(0.997564), qf2vt(0.998630),
- qf2vt(0.999391), qf2vt(0.999848), qf2vt(1.000000), qf2vt(0.999848),
- qf2vt(0.999391), qf2vt(0.998630), qf2vt(0.997564), qf2vt(0.996195),
- qf2vt(0.994522), qf2vt(0.992546), qf2vt(0.990268), qf2vt(0.987688),
- qf2vt(0.984808), qf2vt(0.981627), qf2vt(0.978148), qf2vt(0.974370),
- qf2vt(0.970296), qf2vt(0.965926), qf2vt(0.961262), qf2vt(0.956305),
- qf2vt(0.951057), qf2vt(0.945519), qf2vt(0.939693), qf2vt(0.933580),
- qf2vt(0.927184), qf2vt(0.920505), qf2vt(0.913545), qf2vt(0.906308),
- qf2vt(0.898794), qf2vt(0.891007), qf2vt(0.882948), qf2vt(0.874620),
- qf2vt(0.866025), qf2vt(0.857167), qf2vt(0.848048), qf2vt(0.838671),
- qf2vt(0.829038), qf2vt(0.819152), qf2vt(0.809017), qf2vt(0.798636),
- qf2vt(0.788011), qf2vt(0.777146), qf2vt(0.766044), qf2vt(0.754710),
- qf2vt(0.743145), qf2vt(0.731354), qf2vt(0.719340), qf2vt(0.707107),
- qf2vt(0.694658), qf2vt(0.681998), qf2vt(0.669131), qf2vt(0.656059),
- qf2vt(0.642788), qf2vt(0.629320), qf2vt(0.615661), qf2vt(0.601815),
- qf2vt(0.587785), qf2vt(0.573576), qf2vt(0.559193), qf2vt(0.544639),
- qf2vt(0.529919), qf2vt(0.515038), qf2vt(0.500000), qf2vt(0.484810),
- qf2vt(0.469472), qf2vt(0.453990), qf2vt(0.438371), qf2vt(0.422618),
- qf2vt(0.406737), qf2vt(0.390731), qf2vt(0.374607), qf2vt(0.358368),
- qf2vt(0.342020), qf2vt(0.325568), qf2vt(0.309017), qf2vt(0.292372),
- qf2vt(0.275637), qf2vt(0.258819), qf2vt(0.241922), qf2vt(0.224951),
- qf2vt(0.207912), qf2vt(0.190809), qf2vt(0.173648), qf2vt(0.156434),
- qf2vt(0.139173), qf2vt(0.121869), qf2vt(0.104528), qf2vt(0.087156),
- qf2vt(0.069756), qf2vt(0.052336), qf2vt(0.034899), qf2vt(0.017452),
- qf2vt(0.000000), qf2vt(-0.017452), qf2vt(-0.034899), qf2vt(-0.052336),
- qf2vt(-0.069756), qf2vt(-0.087156), qf2vt(-0.104528), qf2vt(-0.121869),
- qf2vt(-0.139173), qf2vt(-0.156434), qf2vt(-0.173648), qf2vt(-0.190809),
- qf2vt(-0.207912), qf2vt(-0.224951), qf2vt(-0.241922), qf2vt(-0.258819),
- qf2vt(-0.275637), qf2vt(-0.292372), qf2vt(-0.309017), qf2vt(-0.325568),
- qf2vt(-0.342020), qf2vt(-0.358368), qf2vt(-0.374607), qf2vt(-0.390731),
- qf2vt(-0.406737), qf2vt(-0.422618), qf2vt(-0.438371), qf2vt(-0.453990),
- qf2vt(-0.469472), qf2vt(-0.484810), qf2vt(-0.500000), qf2vt(-0.515038),
- qf2vt(-0.529919), qf2vt(-0.544639), qf2vt(-0.559193), qf2vt(-0.573576),
- qf2vt(-0.587785), qf2vt(-0.601815), qf2vt(-0.615661), qf2vt(-0.629320),
- qf2vt(-0.642788), qf2vt(-0.656059), qf2vt(-0.669131), qf2vt(-0.681998),
- qf2vt(-0.694658), qf2vt(-0.707107), qf2vt(-0.719340), qf2vt(-0.731354),
- qf2vt(-0.743145), qf2vt(-0.754710), qf2vt(-0.766044), qf2vt(-0.777146),
- qf2vt(-0.788011), qf2vt(-0.798636), qf2vt(-0.809017), qf2vt(-0.819152),
- qf2vt(-0.829038), qf2vt(-0.838671), qf2vt(-0.848048), qf2vt(-0.857167),
- qf2vt(-0.866025), qf2vt(-0.874620), qf2vt(-0.882948), qf2vt(-0.891007),
- qf2vt(-0.898794), qf2vt(-0.906308), qf2vt(-0.913545), qf2vt(-0.920505),
- qf2vt(-0.927184), qf2vt(-0.933580), qf2vt(-0.939693), qf2vt(-0.945519),
- qf2vt(-0.951057), qf2vt(-0.956305), qf2vt(-0.961262), qf2vt(-0.965926),
- qf2vt(-0.970296), qf2vt(-0.974370), qf2vt(-0.978148), qf2vt(-0.981627),
- qf2vt(-0.984808), qf2vt(-0.987688), qf2vt(-0.990268), qf2vt(-0.992546),
- qf2vt(-0.994522), qf2vt(-0.996195), qf2vt(-0.997564), qf2vt(-0.998630),
- qf2vt(-0.999391), qf2vt(-0.999848), qf2vt(-1.000000), qf2vt(-0.999848),
- qf2vt(-0.999391), qf2vt(-0.998630), qf2vt(-0.997564), qf2vt(-0.996195),
- qf2vt(-0.994522), qf2vt(-0.992546), qf2vt(-0.990268), qf2vt(-0.987688),
- qf2vt(-0.984808), qf2vt(-0.981627), qf2vt(-0.978148), qf2vt(-0.974370),
- qf2vt(-0.970296), qf2vt(-0.965926), qf2vt(-0.961262), qf2vt(-0.956305),
- qf2vt(-0.951057), qf2vt(-0.945519), qf2vt(-0.939693), qf2vt(-0.933580),
- qf2vt(-0.927184), qf2vt(-0.920505), qf2vt(-0.913545), qf2vt(-0.906308),
- qf2vt(-0.898794), qf2vt(-0.891007), qf2vt(-0.882948), qf2vt(-0.874620),
- qf2vt(-0.866025), qf2vt(-0.857167), qf2vt(-0.848048), qf2vt(-0.838671),
- qf2vt(-0.829038), qf2vt(-0.819152), qf2vt(-0.809017), qf2vt(-0.798636),
- qf2vt(-0.788011), qf2vt(-0.777146), qf2vt(-0.766044), qf2vt(-0.754710),
- qf2vt(-0.743145), qf2vt(-0.731354), qf2vt(-0.719340), qf2vt(-0.707107),
- qf2vt(-0.694658), qf2vt(-0.681998), qf2vt(-0.669131), qf2vt(-0.656059),
- qf2vt(-0.642788), qf2vt(-0.629320), qf2vt(-0.615661), qf2vt(-0.601815),
- qf2vt(-0.587785), qf2vt(-0.573576), qf2vt(-0.559193), qf2vt(-0.544639),
- qf2vt(-0.529919), qf2vt(-0.515038), qf2vt(-0.500000), qf2vt(-0.484810),
- qf2vt(-0.469472), qf2vt(-0.453990), qf2vt(-0.438371), qf2vt(-0.422618),
- qf2vt(-0.406737), qf2vt(-0.390731), qf2vt(-0.374607), qf2vt(-0.358368),
- qf2vt(-0.342020), qf2vt(-0.325568), qf2vt(-0.309017), qf2vt(-0.292372),
- qf2vt(-0.275637), qf2vt(-0.258819), qf2vt(-0.241922), qf2vt(-0.224951),
- qf2vt(-0.207912), qf2vt(-0.190809), qf2vt(-0.173648), qf2vt(-0.156434),
- qf2vt(-0.139173), qf2vt(-0.121869), qf2vt(-0.104528), qf2vt(-0.087156),
- qf2vt(-0.069756), qf2vt(-0.052336), qf2vt(-0.034899), qf2vt(-0.017452)
-};
-
-void qt_math3d_sincos(qreal angle, qrealinner *s, qrealinner *c)
-{
- if (angle == qFloor(angle)) {
- // The angle is an integer number of degrees, so look up the results.
- int a = (int)angle;
- if (a >= 0)
- a = (a % 360);
- else
- a = 360 - (-a % 360);
- s->setBits(sinTable[a]);
- c->setBits(sinTable[(a + 90) % 360]);
- } else {
- qreal a = angle * M_PI / 180.0f;
- *s = qSin(a);
- *c = qCos(a);
- }
-}
-
-#else
-
-void qt_math3d_sincos(qreal angle, qrealinner *s, qrealinner *c)
-{
- qreal a = angle * M_PI / 180.0f;
- *s = qSin(a);
- *c = qCos(a);
-}
-
-#endif
-
-QT_END_NAMESPACE
diff --git a/src/gui/math3d/qmath3dutil_p.h b/src/gui/math3d/qmath3dutil_p.h
deleted file mode 100644
index fa4c156..0000000
--- a/src/gui/math3d/qmath3dutil_p.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the $MODULE$ of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMATH3DUTIL_P_H
-#define QMATH3DUTIL_P_H
-
-#include <QtGui/qmath3dglobal.h>
-#include <QtCore/qmath.h>
-
-QT_BEGIN_NAMESPACE
-
-#ifdef QT_GL_FIXED_PREFERRED
-#define qvtsqrt(x) ((x).sqrtF())
-#else
-#define qvtsqrt(x) qSqrt((x))
-#endif
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-void qt_math3d_sincos(qreal degrees, qrealinner *s, qrealinner *c);
-
-#ifdef QT_GL_FIXED_PREFERRED
-
-inline qrealinner qf2vt_round(qreal x)
-{
- QFixedPt<16> result;
- if (x >= 0.0f)
- result.setBits(int(x * 65536.0f + 0.5f));
- else
- result.setBits(int(x * 65536.0f - 0.5f));
- return result;
-}
-
-// Helper macros for computing dot products without losing precision.
-// In fixed-point mode, a 64-bit intermediate result is used.
-#define qvtmul64(x,y) ((qint64((x).bits())) * (qint64((y).bits())))
-#define qvtsqrt64(x) \
- (qt_math3d_fixed_sqrt((x) << 16) / (qreal)(1 << 24))
-#define qvtdot64(x) ((x) / (qreal)(((qint64)1) << 32))
-
-#else
-
-inline qrealinner qf2vt_round(qreal x)
-{
- return x;
-}
-
-#define qvtmul64(x,y) ((x) * (y))
-#define qvtsqrt64(x) (qvtsqrt((x)))
-#define qvtdot64(x) ((x))
-
-#endif
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp
index bcb3066..e00d772 100644
--- a/src/gui/math3d/qmatrix4x4.cpp
+++ b/src/gui/math3d/qmatrix4x4.cpp
@@ -40,7 +40,6 @@
****************************************************************************/
#include "qmatrix4x4.h"
-#include "qmath3dutil_p.h"
#include <QtCore/qmath.h>
#include <QtGui/qmatrix.h>
#include <QtGui/qtransform.h>
@@ -106,7 +105,7 @@ QMatrix4x4::QMatrix4x4(const qreal *values)
#if !defined(QT_NO_MEMBER_TEMPLATES) || defined(Q_QDOC)
/*!
- \fn QMatrix4x4::QMatrix4x4(const QGenericMatrix<N, M, qreal, qrealinner>& matrix)
+ \fn QMatrix4x4::QMatrix4x4(const QGenericMatrix<N, M, qreal, float>& matrix)
Constructs a 4x4 matrix from the left-most 4 columns and top-most
4 rows of \a matrix. If \a matrix has less than 4 columns or rows,
@@ -117,7 +116,7 @@ QMatrix4x4::QMatrix4x4(const qreal *values)
*/
/*!
- \fn QGenericMatrix<N, M, qreal, qrealinner> QMatrix4x4::toGenericMatrix() const
+ \fn QGenericMatrix<N, M, qreal, float> QMatrix4x4::toGenericMatrix() const
Constructs a NxM generic matrix from the left-most N columns and
top-most M rows of this 4x4 matrix. If N or M is greater than 4,
@@ -130,7 +129,7 @@ QMatrix4x4::QMatrix4x4(const qreal *values)
#endif
/*!
- \fn QMatrix4x4 qGenericMatrixToMatrix4x4(const QGenericMatrix<N, M, qreal, qrealinner>& matrix)
+ \fn QMatrix4x4 qGenericMatrixToMatrix4x4(const QGenericMatrix<N, M, qreal, float>& matrix)
\relates QMatrix4x4
Returns a 4x4 matrix constructed from the left-most 4 columns and
@@ -142,7 +141,7 @@ QMatrix4x4::QMatrix4x4(const qreal *values)
*/
/*!
- \fn QGenericMatrix<N, M, qreal, qrealinner> qGenericMatrixFromMatrix4x4(const QMatrix4x4& matrix)
+ \fn QGenericMatrix<N, M, qreal, float> qGenericMatrixFromMatrix4x4(const QMatrix4x4& matrix)
\relates QMatrix4x4
Returns a NxM generic matrix constructed from the left-most N columns
@@ -156,7 +155,7 @@ QMatrix4x4::QMatrix4x4(const qreal *values)
/*!
\internal
*/
-QMatrix4x4::QMatrix4x4(const qrealinner *values, int cols, int rows)
+QMatrix4x4::QMatrix4x4(const float *values, int cols, int rows)
{
for (int col = 0; col < 4; ++col) {
for (int row = 0; row < 4; ++row) {
@@ -244,7 +243,7 @@ QMatrix4x4::QMatrix4x4(const QTransform& transform)
*/
/*!
- \fn qrealinner& QMatrix4x4::operator()(int row, int column)
+ \fn float& QMatrix4x4::operator()(int row, int column)
Returns a reference to the element at position (\a row, \a column)
in this matrix so that the element can be assigned to.
@@ -316,8 +315,8 @@ QMatrix4x4::QMatrix4x4(const QTransform& transform)
// | A B C |
// M = | D E F | det(M) = A * (EI - HF) - B * (DI - GF) + C * (DH - GE)
// | G H I |
-static inline qrealinner matrixDet3
- (const qrealinner m[4][4], int col0, int col1, int col2,
+static inline float matrixDet3
+ (const float m[4][4], int col0, int col1, int col2,
int row0, int row1, int row2)
{
return m[col0][row0] *
@@ -332,9 +331,9 @@ static inline qrealinner matrixDet3
}
// Calculate the determinant of a 4x4 matrix.
-static inline qrealinner matrixDet4(const qrealinner m[4][4])
+static inline float matrixDet4(const float m[4][4])
{
- qrealinner det;
+ float det;
det = m[0][0] * matrixDet3(m, 1, 2, 3, 1, 2, 3);
det -= m[1][0] * matrixDet3(m, 0, 2, 3, 1, 2, 3);
det += m[2][0] * matrixDet3(m, 0, 1, 3, 1, 2, 3);
@@ -347,7 +346,7 @@ static inline qrealinner matrixDet4(const qrealinner m[4][4])
*/
qreal QMatrix4x4::determinant() const
{
- return qt_math3d_convert<qreal, qrealinner>(matrixDet4(m));
+ return qreal(matrixDet4(m));
}
/*!
@@ -386,13 +385,13 @@ QMatrix4x4 QMatrix4x4::inverted(bool *invertible) const
QMatrix4x4 inv(1); // The "1" says to not load the identity.
- qrealinner det = matrixDet4(m);
+ float det = matrixDet4(m);
if (det == 0.0f) {
if (invertible)
*invertible = false;
return QMatrix4x4();
}
- det = qrealinner(1.0f) / det;
+ det = 1.0f / det;
inv.m[0][0] = matrixDet3(m, 1, 2, 3, 1, 2, 3) * det;
inv.m[0][1] = -matrixDet3(m, 0, 2, 3, 1, 2, 3) * det;
@@ -434,18 +433,18 @@ QMatrix3x3 QMatrix4x4::normalMatrix() const
} else if (flagBits == Scale || flagBits == (Translation | Scale)) {
if (m[0][0] == 0.0f || m[1][1] == 0.0f || m[2][2] == 0.0f)
return inv;
- inv.data()[0] = qrealinner(1.0f) / m[0][0];
- inv.data()[4] = qrealinner(1.0f) / m[1][1];
- inv.data()[8] = qrealinner(1.0f) / m[2][2];
+ inv.data()[0] = 1.0f / m[0][0];
+ inv.data()[4] = 1.0f / m[1][1];
+ inv.data()[8] = 1.0f / m[2][2];
return inv;
}
- qrealinner det = matrixDet3(m, 0, 1, 2, 0, 1, 2);
+ float det = matrixDet3(m, 0, 1, 2, 0, 1, 2);
if (det == 0.0f)
return inv;
- det = qrealinner(1.0f) / det;
+ det = 1.0f / det;
- qrealinner *invm = inv.data();
+ float *invm = inv.data();
// Invert and transpose in a single step.
invm[0 + 0 * 3] = (m[1][1] * m[2][2] - m[2][1] * m[1][2]) * det;
@@ -507,23 +506,22 @@ QMatrix4x4 QMatrix4x4::transposed() const
*/
QMatrix4x4& QMatrix4x4::operator/=(qreal divisor)
{
- qrealinner d(divisor);
- m[0][0] /= d;
- m[0][1] /= d;
- m[0][2] /= d;
- m[0][3] /= d;
- m[1][0] /= d;
- m[1][1] /= d;
- m[1][2] /= d;
- m[1][3] /= d;
- m[2][0] /= d;
- m[2][1] /= d;
- m[2][2] /= d;
- m[2][3] /= d;
- m[3][0] /= d;
- m[3][1] /= d;
- m[3][2] /= d;
- m[3][3] /= d;
+ m[0][0] /= divisor;
+ m[0][1] /= divisor;
+ m[0][2] /= divisor;
+ m[0][3] /= divisor;
+ m[1][0] /= divisor;
+ m[1][1] /= divisor;
+ m[1][2] /= divisor;
+ m[1][3] /= divisor;
+ m[2][0] /= divisor;
+ m[2][1] /= divisor;
+ m[2][2] /= divisor;
+ m[2][3] /= divisor;
+ m[3][0] /= divisor;
+ m[3][1] /= divisor;
+ m[3][2] /= divisor;
+ m[3][3] /= divisor;
flagBits = General;
return *this;
}
@@ -665,23 +663,22 @@ QMatrix4x4& QMatrix4x4::operator/=(qreal divisor)
QMatrix4x4 operator/(const QMatrix4x4& matrix, qreal divisor)
{
QMatrix4x4 m(1); // The "1" says to not load the identity.
- qrealinner d(divisor);
- m.m[0][0] = matrix.m[0][0] / d;
- m.m[0][1] = matrix.m[0][1] / d;
- m.m[0][2] = matrix.m[0][2] / d;
- m.m[0][3] = matrix.m[0][3] / d;
- m.m[1][0] = matrix.m[1][0] / d;
- m.m[1][1] = matrix.m[1][1] / d;
- m.m[1][2] = matrix.m[1][2] / d;
- m.m[1][3] = matrix.m[1][3] / d;
- m.m[2][0] = matrix.m[2][0] / d;
- m.m[2][1] = matrix.m[2][1] / d;
- m.m[2][2] = matrix.m[2][2] / d;
- m.m[2][3] = matrix.m[2][3] / d;
- m.m[3][0] = matrix.m[3][0] / d;
- m.m[3][1] = matrix.m[3][1] / d;
- m.m[3][2] = matrix.m[3][2] / d;
- m.m[3][3] = matrix.m[3][3] / d;
+ m.m[0][0] = matrix.m[0][0] / divisor;
+ m.m[0][1] = matrix.m[0][1] / divisor;
+ m.m[0][2] = matrix.m[0][2] / divisor;
+ m.m[0][3] = matrix.m[0][3] / divisor;
+ m.m[1][0] = matrix.m[1][0] / divisor;
+ m.m[1][1] = matrix.m[1][1] / divisor;
+ m.m[1][2] = matrix.m[1][2] / divisor;
+ m.m[1][3] = matrix.m[1][3] / divisor;
+ m.m[2][0] = matrix.m[2][0] / divisor;
+ m.m[2][1] = matrix.m[2][1] / divisor;
+ m.m[2][2] = matrix.m[2][2] / divisor;
+ m.m[2][3] = matrix.m[2][3] / divisor;
+ m.m[3][0] = matrix.m[3][0] / divisor;
+ m.m[3][1] = matrix.m[3][1] / divisor;
+ m.m[3][2] = matrix.m[3][2] / divisor;
+ m.m[3][3] = matrix.m[3][3] / divisor;
return m;
}
@@ -703,9 +700,9 @@ QMatrix4x4 operator/(const QMatrix4x4& matrix, qreal divisor)
*/
QMatrix4x4& QMatrix4x4::scale(const QVector3D& vector)
{
- qrealinner vx = vector.xp;
- qrealinner vy = vector.yp;
- qrealinner vz = vector.zp;
+ float vx = vector.xp;
+ float vy = vector.yp;
+ float vz = vector.zp;
if (flagBits == Identity) {
m[0][0] = vx;
m[1][1] = vy;
@@ -749,9 +746,9 @@ QMatrix4x4& QMatrix4x4::scale(const QVector3D& vector)
*/
QMatrix4x4& QMatrix4x4::scale(qreal x, qreal y, qreal z)
{
- qrealinner vx(x);
- qrealinner vy(y);
- qrealinner vz(z);
+ float vx(x);
+ float vy(y);
+ float vz(z);
if (flagBits == Identity) {
m[0][0] = vx;
m[1][1] = vy;
@@ -794,34 +791,33 @@ QMatrix4x4& QMatrix4x4::scale(qreal x, qreal y, qreal z)
*/
QMatrix4x4& QMatrix4x4::scale(qreal factor)
{
- qrealinner f(factor);
if (flagBits == Identity) {
- m[0][0] = f;
- m[1][1] = f;
- m[2][2] = f;
+ m[0][0] = factor;
+ m[1][1] = factor;
+ m[2][2] = factor;
flagBits = Scale;
} else if (flagBits == Scale || flagBits == (Scale | Translation)) {
- m[0][0] *= f;
- m[1][1] *= f;
- m[2][2] *= f;
+ m[0][0] *= factor;
+ m[1][1] *= factor;
+ m[2][2] *= factor;
} else if (flagBits == Translation) {
- m[0][0] = f;
- m[1][1] = f;
- m[2][2] = f;
+ m[0][0] = factor;
+ m[1][1] = factor;
+ m[2][2] = factor;
flagBits |= Scale;
} else {
- m[0][0] *= f;
- m[0][1] *= f;
- m[0][2] *= f;
- m[0][3] *= f;
- m[1][0] *= f;
- m[1][1] *= f;
- m[1][2] *= f;
- m[1][3] *= f;
- m[2][0] *= f;
- m[2][1] *= f;
- m[2][2] *= f;
- m[2][3] *= f;
+ m[0][0] *= factor;
+ m[0][1] *= factor;
+ m[0][2] *= factor;
+ m[0][3] *= factor;
+ m[1][0] *= factor;
+ m[1][1] *= factor;
+ m[1][2] *= factor;
+ m[1][3] *= factor;
+ m[2][0] *= factor;
+ m[2][1] *= factor;
+ m[2][2] *= factor;
+ m[2][3] *= factor;
flagBits = General;
}
return *this;
@@ -836,9 +832,9 @@ QMatrix4x4& QMatrix4x4::scale(qreal factor)
*/
QMatrix4x4& QMatrix4x4::translate(const QVector3D& vector)
{
- qrealinner vx = vector.xp;
- qrealinner vy = vector.yp;
- qrealinner vz = vector.zp;
+ float vx = vector.xp;
+ float vy = vector.yp;
+ float vz = vector.zp;
if (flagBits == Identity) {
m[3][0] = vx;
m[3][1] = vy;
@@ -882,9 +878,9 @@ QMatrix4x4& QMatrix4x4::translate(const QVector3D& vector)
*/
QMatrix4x4& QMatrix4x4::translate(qreal x, qreal y, qreal z)
{
- qrealinner vx(x);
- qrealinner vy(y);
- qrealinner vz(z);
+ float vx(x);
+ float vy(y);
+ float vz(z);
if (flagBits == Identity) {
m[3][0] = vx;
m[3][1] = vy;
@@ -931,6 +927,10 @@ QMatrix4x4& QMatrix4x4::rotate(qreal angle, const QVector3D& vector)
#endif
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
/*!
\overload
@@ -942,8 +942,10 @@ QMatrix4x4& QMatrix4x4::rotate(qreal angle, const QVector3D& vector)
QMatrix4x4& QMatrix4x4::rotate(qreal angle, qreal x, qreal y, qreal z)
{
QMatrix4x4 m(1); // The "1" says to not load the identity.
- qrealinner c, s, ic;
- qt_math3d_sincos(angle, &s, &c);
+ qreal a = angle * M_PI / 180.0f;
+ qreal c = qCos(a);
+ qreal s = qSin(a);
+ qreal ic;
bool quick = false;
if (x == 0.0f) {
if (y == 0.0f) {
@@ -993,27 +995,24 @@ QMatrix4x4& QMatrix4x4::rotate(qreal angle, qreal x, qreal y, qreal z)
quick = true;
}
if (!quick) {
- qrealinner vx(x);
- qrealinner vy(y);
- qrealinner vz(z);
- qrealinner len(qvtsqrt(vx * vx + vy * vy + vz * vz));
+ qreal len = qSqrt(x * x + y * y + z * z);
if (len != 0) {
- vx /= len;
- vy /= len;
- vz /= len;
+ x /= len;
+ y /= len;
+ z /= len;
}
ic = 1.0f - c;
- m.m[0][0] = vx * vx * ic + c;
- m.m[1][0] = vx * vy * ic - vz * s;
- m.m[2][0] = vx * vz * ic + vy * s;
+ m.m[0][0] = x * x * ic + c;
+ m.m[1][0] = x * y * ic - z * s;
+ m.m[2][0] = x * z * ic + y * s;
m.m[3][0] = 0.0f;
- m.m[0][1] = vy * vx * ic + vz * s;
- m.m[1][1] = vy * vy * ic + c;
- m.m[2][1] = vy * vz * ic - vx * s;
+ m.m[0][1] = y * x * ic + z * s;
+ m.m[1][1] = y * y * ic + c;
+ m.m[2][1] = y * z * ic - x * s;
m.m[3][1] = 0.0f;
- m.m[0][2] = vx * vz * ic - vy * s;
- m.m[1][2] = vy * vz * ic + vx * s;
- m.m[2][2] = vz * vz * ic + c;
+ m.m[0][2] = x * z * ic - y * s;
+ m.m[1][2] = y * z * ic + x * s;
+ m.m[2][2] = z * z * ic + c;
m.m[3][2] = 0.0f;
m.m[0][3] = 0.0f;
m.m[1][3] = 0.0f;
@@ -1043,15 +1042,15 @@ QMatrix4x4& QMatrix4x4::rotate(const QQuaternion& quaternion)
// Algorithm from:
// http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q54
QMatrix4x4 m(1);
- qrealinner xx = quaternion.xp * quaternion.xp;
- qrealinner xy = quaternion.xp * quaternion.yp;
- qrealinner xz = quaternion.xp * quaternion.zp;
- qrealinner xw = quaternion.xp * quaternion.wp;
- qrealinner yy = quaternion.yp * quaternion.yp;
- qrealinner yz = quaternion.yp * quaternion.zp;
- qrealinner yw = quaternion.yp * quaternion.wp;
- qrealinner zz = quaternion.zp * quaternion.zp;
- qrealinner zw = quaternion.zp * quaternion.wp;
+ float xx = quaternion.xp * quaternion.xp;
+ float xy = quaternion.xp * quaternion.yp;
+ float xz = quaternion.xp * quaternion.zp;
+ float xw = quaternion.xp * quaternion.wp;
+ float yy = quaternion.yp * quaternion.yp;
+ float yz = quaternion.yp * quaternion.zp;
+ float yw = quaternion.yp * quaternion.wp;
+ float zz = quaternion.zp * quaternion.zp;
+ float zw = quaternion.zp * quaternion.wp;
m.m[0][0] = 1.0f - 2 * (yy + zz);
m.m[1][0] = 2 * (xy - zw);
m.m[2][0] = 2 * (xz + yw);
@@ -1137,33 +1136,33 @@ QMatrix4x4& QMatrix4x4::ortho(qreal left, qreal right, qreal bottom, qreal top,
// which will be more efficient to modify with further
// transformations than producing a "General" matrix.
translate(QVector3D
- (qf2vt_round(-(left + right) / width),
- qf2vt_round(-(top + bottom) / invheight),
+ (-(left + right) / width,
+ -(top + bottom) / invheight,
0.0f, 1));
scale(QVector3D
- (qf2vt_round(2.0f / width),
- qf2vt_round(2.0f / invheight),
+ (2.0f / width,
+ 2.0f / invheight,
-1.0f, 1));
return *this;
}
#endif
QMatrix4x4 m(1);
- m.m[0][0] = qf2vt_round(2.0f / width);
- m.m[1][0] = qf2vt_round(0.0f);
- m.m[2][0] = qf2vt_round(0.0f);
- m.m[3][0] = qf2vt_round(-(left + right) / width);
- m.m[0][1] = qf2vt_round(0.0f);
- m.m[1][1] = qf2vt_round(2.0f / invheight);
- m.m[2][1] = qf2vt_round(0.0f);
- m.m[3][1] = qf2vt_round(-(top + bottom) / invheight);
- m.m[0][2] = qf2vt_round(0.0f);
- m.m[1][2] = qf2vt_round(0.0f);
- m.m[2][2] = qf2vt_round(-2.0f / clip);
- m.m[3][2] = qf2vt_round(-(nearPlane + farPlane) / clip);
- m.m[0][3] = qf2vt_round(0.0f);
- m.m[1][3] = qf2vt_round(0.0f);
- m.m[2][3] = qf2vt_round(0.0f);
- m.m[3][3] = qf2vt_round(1.0f);
+ m.m[0][0] = 2.0f / width;
+ m.m[1][0] = 0.0f;
+ m.m[2][0] = 0.0f;
+ m.m[3][0] = -(left + right) / width;
+ m.m[0][1] = 0.0f;
+ m.m[1][1] = 2.0f / invheight;
+ m.m[2][1] = 0.0f;
+ m.m[3][1] = -(top + bottom) / invheight;
+ m.m[0][2] = 0.0f;
+ m.m[1][2] = 0.0f;
+ m.m[2][2] = -2.0f / clip;
+ m.m[3][2] = -(nearPlane + farPlane) / clip;
+ m.m[0][3] = 0.0f;
+ m.m[1][3] = 0.0f;
+ m.m[2][3] = 0.0f;
+ m.m[3][3] = 1.0f;
// Apply the projection.
*this *= m;
@@ -1189,22 +1188,22 @@ QMatrix4x4& QMatrix4x4::frustum(qreal left, qreal right, qreal bottom, qreal top
qreal width = right - left;
qreal invheight = top - bottom;
qreal clip = farPlane - nearPlane;
- m.m[0][0] = qf2vt_round(2.0f * nearPlane / width);
- m.m[1][0] = qf2vt_round(0.0f);
- m.m[2][0] = qf2vt_round((left + right) / width);
- m.m[3][0] = qf2vt_round(0.0f);
- m.m[0][1] = qf2vt_round(0.0f);
- m.m[1][1] = qf2vt_round(2.0f * nearPlane / invheight);
- m.m[2][1] = qf2vt_round((top + bottom) / invheight);
- m.m[3][1] = qf2vt_round(0.0f);
- m.m[0][2] = qf2vt_round(0.0f);
- m.m[1][2] = qf2vt_round(0.0f);
- m.m[2][2] = qf2vt_round(-(nearPlane + farPlane) / clip);
- m.m[3][2] = qf2vt_round(-(2.0f * nearPlane * farPlane) / clip);
- m.m[0][3] = qf2vt_round(0.0f);
- m.m[1][3] = qf2vt_round(0.0f);
- m.m[2][3] = qf2vt_round(-1.0f);
- m.m[3][3] = qf2vt_round(0.0f);
+ m.m[0][0] = 2.0f * nearPlane / width;
+ m.m[1][0] = 0.0f;
+ m.m[2][0] = (left + right) / width;
+ m.m[3][0] = 0.0f;
+ m.m[0][1] = 0.0f;
+ m.m[1][1] = 2.0f * nearPlane / invheight;
+ m.m[2][1] = (top + bottom) / invheight;
+ m.m[3][1] = 0.0f;
+ m.m[0][2] = 0.0f;
+ m.m[1][2] = 0.0f;
+ m.m[2][2] = -(nearPlane + farPlane) / clip;
+ m.m[3][2] = -2.0f * nearPlane * farPlane / clip;
+ m.m[0][3] = 0.0f;
+ m.m[1][3] = 0.0f;
+ m.m[2][3] = -1.0f;
+ m.m[3][3] = 0.0f;
// Apply the projection.
*this *= m;
@@ -1234,22 +1233,22 @@ QMatrix4x4& QMatrix4x4::perspective(qreal angle, qreal aspect, qreal nearPlane,
return *this;
qreal cotan = qCos(radians) / sine;
qreal clip = farPlane - nearPlane;
- m.m[0][0] = qf2vt_round(cotan / aspect);
- m.m[1][0] = qf2vt_round(0.0f);
- m.m[2][0] = qf2vt_round(0.0f);
- m.m[3][0] = qf2vt_round(0.0f);
- m.m[0][1] = qf2vt_round(0.0f);
- m.m[1][1] = qf2vt_round(cotan);
- m.m[2][1] = qf2vt_round(0.0f);
- m.m[3][1] = qf2vt_round(0.0f);
- m.m[0][2] = qf2vt_round(0.0f);
- m.m[1][2] = qf2vt_round(0.0f);
- m.m[2][2] = qf2vt_round(-(nearPlane + farPlane) / clip);
- m.m[3][2] = qf2vt_round(-(2.0f * nearPlane * farPlane) / clip);
- m.m[0][3] = qf2vt_round(0.0f);
- m.m[1][3] = qf2vt_round(0.0f);
- m.m[2][3] = qf2vt_round(-1.0f);
- m.m[3][3] = qf2vt_round(0.0f);
+ m.m[0][0] = cotan / aspect;
+ m.m[1][0] = 0.0f;
+ m.m[2][0] = 0.0f;
+ m.m[3][0] = 0.0f;
+ m.m[0][1] = 0.0f;
+ m.m[1][1] = cotan;
+ m.m[2][1] = 0.0f;
+ m.m[3][1] = 0.0f;
+ m.m[0][2] = 0.0f;
+ m.m[1][2] = 0.0f;
+ m.m[2][2] = -(nearPlane + farPlane) / clip;
+ m.m[3][2] = -(2.0f * nearPlane * farPlane) / clip;
+ m.m[0][3] = 0.0f;
+ m.m[1][3] = 0.0f;
+ m.m[2][3] = -1.0f;
+ m.m[3][3] = 0.0f;
// Apply the projection.
*this *= m;
@@ -1339,7 +1338,7 @@ void QMatrix4x4::toValueArray(qreal *values) const
{
for (int row = 0; row < 4; ++row)
for (int col = 0; col < 4; ++col)
- values[row * 4 + col] = qt_math3d_convert<qreal, qrealinner>(m[col][row]);
+ values[row * 4 + col] = qreal(m[col][row]);
}
/*!
@@ -1351,12 +1350,9 @@ void QMatrix4x4::toValueArray(qreal *values) const
*/
QMatrix QMatrix4x4::toAffine() const
{
- return QMatrix(qt_math3d_convert<qreal, qrealinner>(m[0][0]),
- qt_math3d_convert<qreal, qrealinner>(m[0][1]),
- qt_math3d_convert<qreal, qrealinner>(m[1][0]),
- qt_math3d_convert<qreal, qrealinner>(m[1][1]),
- qt_math3d_convert<qreal, qrealinner>(m[3][0]),
- qt_math3d_convert<qreal, qrealinner>(m[3][1]));
+ return QMatrix(qreal(m[0][0]), qreal(m[0][1]),
+ qreal(m[1][0]), qreal(m[1][1]),
+ qreal(m[3][0]), qreal(m[3][1]));
}
/*!
@@ -1368,15 +1364,9 @@ QMatrix QMatrix4x4::toAffine() const
*/
QTransform QMatrix4x4::toTransform() const
{
- return QTransform(qt_math3d_convert<qreal, qrealinner>(m[0][0]),
- qt_math3d_convert<qreal, qrealinner>(m[0][1]),
- qt_math3d_convert<qreal, qrealinner>(m[0][3]),
- qt_math3d_convert<qreal, qrealinner>(m[1][0]),
- qt_math3d_convert<qreal, qrealinner>(m[1][1]),
- qt_math3d_convert<qreal, qrealinner>(m[1][3]),
- qt_math3d_convert<qreal, qrealinner>(m[3][0]),
- qt_math3d_convert<qreal, qrealinner>(m[3][1]),
- qt_math3d_convert<qreal, qrealinner>(m[3][3]));
+ return QTransform(qreal(m[0][0]), qreal(m[0][1]), qreal(m[0][3]),
+ qreal(m[1][0]), qreal(m[1][1]), qreal(m[1][3]),
+ qreal(m[3][0]), qreal(m[3][1]), qreal(m[3][3]));
}
/*!
@@ -1442,7 +1432,7 @@ QTransform QMatrix4x4::toTransform() const
*/
/*!
- \fn qrealinner *QMatrix4x4::data()
+ \fn float *QMatrix4x4::data()
Returns a pointer to the raw data of this matrix. This is indended
for use with raw GL functions.
@@ -1451,7 +1441,7 @@ QTransform QMatrix4x4::toTransform() const
*/
/*!
- \fn const qrealinner *QMatrix4x4::data() const
+ \fn const float *QMatrix4x4::data() const
Returns a constant pointer to the raw data of this matrix.
This is indended for use with raw GL functions.
@@ -1460,7 +1450,7 @@ QTransform QMatrix4x4::toTransform() const
*/
/*!
- \fn const qrealinner *QMatrix4x4::constData() const
+ \fn const float *QMatrix4x4::constData() const
Returns a constant pointer to the raw data of this matrix.
This is indended for use with raw GL functions.
@@ -1519,12 +1509,12 @@ void QMatrix4x4::extractAxisRotation(qreal &angle, QVector3D &axis) const
{
// Orientation is dependent on the upper 3x3 matrix; subtract the
// homogeneous scaling element from the trace of the 4x4 matrix
- qrealinner tr = m[0][0] + m[1][1] + m[2][2];
- qreal cosa = qt_math3d_convert<qreal, qrealinner>(0.5f * (tr - 1.0f));
+ float tr = m[0][0] + m[1][1] + m[2][2];
+ qreal cosa = qreal(0.5f * (tr - 1.0f));
angle = acos(cosa) * 180.0f / M_PI;
// Any axis will work if r is zero (means no rotation)
- if (qFuzzyCompare(angle, (qreal)0.0f)) {
+ if (qFuzzyIsNull(angle)) {
axis.setX(1.0f);
axis.setY(0.0f);
axis.setZ(0.0f);
@@ -1540,11 +1530,11 @@ void QMatrix4x4::extractAxisRotation(qreal &angle, QVector3D &axis) const
}
// rads == PI
- qrealinner tmp;
+ float tmp;
// r00 is maximum
if ((m[0][0] >= m[2][2]) && (m[0][0] >= m[1][1])) {
- axis.xp = 0.5f * qvtsqrt(m[0][0] - m[1][1] - m[2][2] + 1.0f);
+ axis.xp = 0.5f * qSqrt(m[0][0] - m[1][1] - m[2][2] + 1.0f);
tmp = 0.5f / axis.x();
axis.yp = m[1][0] * tmp;
axis.zp = m[2][0] * tmp;
@@ -1552,7 +1542,7 @@ void QMatrix4x4::extractAxisRotation(qreal &angle, QVector3D &axis) const
// r11 is maximum
if ((m[1][1] >= m[2][2]) && (m[1][1] >= m[0][0])) {
- axis.yp = 0.5f * qvtsqrt(m[1][1] - m[0][0] - m[2][2] + 1.0f);
+ axis.yp = 0.5f * qSqrt(m[1][1] - m[0][0] - m[2][2] + 1.0f);
tmp = 0.5f / axis.y();
axis.xp = tmp * m[1][0];
axis.zp = tmp * m[2][1];
@@ -1560,7 +1550,7 @@ void QMatrix4x4::extractAxisRotation(qreal &angle, QVector3D &axis) const
// r22 is maximum
if ((m[2][2] >= m[1][1]) && (m[2][2] >= m[0][0])) {
- axis.zp = 0.5f * qvtsqrt(m[2][2] - m[0][0] - m[1][1] + 1.0f);
+ axis.zp = 0.5f * qSqrt(m[2][2] - m[0][0] - m[1][1] + 1.0f);
tmp = 0.5f / axis.z();
axis.xp = m[2][0]*tmp;
axis.yp = m[2][1]*tmp;
diff --git a/src/gui/math3d/qmatrix4x4.h b/src/gui/math3d/qmatrix4x4.h
index 6428b20..2b485c1 100644
--- a/src/gui/math3d/qmatrix4x4.h
+++ b/src/gui/math3d/qmatrix4x4.h
@@ -70,14 +70,14 @@ public:
qreal m41, qreal m42, qreal m43, qreal m44);
#if !defined(QT_NO_MEMBER_TEMPLATES) || defined(Q_QDOC)
template <int N, int M>
- explicit QMatrix4x4(const QGenericMatrix<N, M, qreal, qrealinner>& matrix);
+ explicit QMatrix4x4(const QGenericMatrix<N, M, qreal, float>& matrix);
#endif
- QMatrix4x4(const qrealinner *values, int cols, int rows);
+ QMatrix4x4(const float *values, int cols, int rows);
QMatrix4x4(const QTransform& transform);
QMatrix4x4(const QMatrix& matrix);
inline qreal operator()(int row, int column) const;
- inline qrealinner& operator()(int row, int column);
+ inline float& operator()(int row, int column);
inline QVector4D column(int index) const;
inline void setColumn(int index, const QVector4D& value);
@@ -171,12 +171,12 @@ public:
#if !defined(QT_NO_MEMBER_TEMPLATES) || defined(Q_QDOC)
template <int N, int M>
- QGenericMatrix<N, M, qreal, qrealinner> toGenericMatrix() const;
+ QGenericMatrix<N, M, qreal, float> toGenericMatrix() const;
#endif
- inline qrealinner *data();
- inline const qrealinner *data() const { return m[0]; }
- inline const qrealinner *constData() const { return m[0]; }
+ inline float *data();
+ inline const float *data() const { return m[0]; }
+ inline const float *constData() const { return m[0]; }
void inferSpecialType();
@@ -185,7 +185,7 @@ public:
#endif
private:
- qrealinner m[4][4]; // Column-major order to match OpenGL.
+ float m[4][4]; // Column-major order to match OpenGL.
int flagBits; // Flag bits from the enum below.
enum {
@@ -219,9 +219,9 @@ inline QMatrix4x4::QMatrix4x4
template <int N, int M>
Q_INLINE_TEMPLATE QMatrix4x4::QMatrix4x4
- (const QGenericMatrix<N, M, qreal, qrealinner>& matrix)
+ (const QGenericMatrix<N, M, qreal, float>& matrix)
{
- const qrealinner *values = matrix.constData();
+ const float *values = matrix.constData();
for (int col = 0; col < 4; ++col) {
for (int row = 0; row < 4; ++row) {
if (col < N && row < M)
@@ -236,10 +236,10 @@ Q_INLINE_TEMPLATE QMatrix4x4::QMatrix4x4
}
template <int N, int M>
-QGenericMatrix<N, M, qreal, qrealinner> QMatrix4x4::toGenericMatrix() const
+QGenericMatrix<N, M, qreal, float> QMatrix4x4::toGenericMatrix() const
{
- QGenericMatrix<N, M, qreal, qrealinner> result;
- qrealinner *values = result.data();
+ QGenericMatrix<N, M, qreal, float> result;
+ float *values = result.data();
for (int col = 0; col < N; ++col) {
for (int row = 0; row < M; ++row) {
if (col < 4 && row < 4)
@@ -258,10 +258,10 @@ QGenericMatrix<N, M, qreal, qrealinner> QMatrix4x4::toGenericMatrix() const
inline qreal QMatrix4x4::operator()(int row, int column) const
{
Q_ASSERT(row >= 0 && row < 4 && column >= 0 && column < 4);
- return qt_math3d_convert<qreal, qrealinner>(m[column][row]);
+ return qreal(m[column][row]);
}
-inline qrealinner& QMatrix4x4::operator()(int row, int column)
+inline float& QMatrix4x4::operator()(int row, int column)
{
Q_ASSERT(row >= 0 && row < 4 && column >= 0 && column < 4);
flagBits = General;
@@ -420,23 +420,22 @@ inline QMatrix4x4& QMatrix4x4::operator*=(const QMatrix4x4& other)
inline QMatrix4x4& QMatrix4x4::operator*=(qreal factor)
{
- qrealinner f(factor);
- m[0][0] *= f;
- m[0][1] *= f;
- m[0][2] *= f;
- m[0][3] *= f;
- m[1][0] *= f;
- m[1][1] *= f;
- m[1][2] *= f;
- m[1][3] *= f;
- m[2][0] *= f;
- m[2][1] *= f;
- m[2][2] *= f;
- m[2][3] *= f;
- m[3][0] *= f;
- m[3][1] *= f;
- m[3][2] *= f;
- m[3][3] *= f;
+ m[0][0] *= factor;
+ m[0][1] *= factor;
+ m[0][2] *= factor;
+ m[0][3] *= factor;
+ m[1][0] *= factor;
+ m[1][1] *= factor;
+ m[1][2] *= factor;
+ m[1][3] *= factor;
+ m[2][0] *= factor;
+ m[2][1] *= factor;
+ m[2][2] *= factor;
+ m[2][3] *= factor;
+ m[3][0] *= factor;
+ m[3][1] *= factor;
+ m[3][2] *= factor;
+ m[3][3] *= factor;
flagBits = General;
return *this;
}
@@ -604,7 +603,7 @@ inline QMatrix4x4 operator*(const QMatrix4x4& m1, const QMatrix4x4& m2)
inline QVector3D operator*(const QVector3D& vector, const QMatrix4x4& matrix)
{
- qrealinner x, y, z, w;
+ float x, y, z, w;
x = vector.xp * matrix.m[0][0] +
vector.yp * matrix.m[0][1] +
vector.zp * matrix.m[0][2] +
@@ -629,7 +628,7 @@ inline QVector3D operator*(const QVector3D& vector, const QMatrix4x4& matrix)
inline QVector3D operator*(const QMatrix4x4& matrix, const QVector3D& vector)
{
- qrealinner x, y, z, w;
+ float x, y, z, w;
x = vector.xp * matrix.m[0][0] +
vector.yp * matrix.m[1][0] +
vector.zp * matrix.m[2][0] +
@@ -658,7 +657,7 @@ inline QVector3D operator*(const QMatrix4x4& matrix, const QVector3D& vector)
inline QVector4D operator*(const QVector4D& vector, const QMatrix4x4& matrix)
{
- qrealinner x, y, z, w;
+ float x, y, z, w;
x = vector.xp * matrix.m[0][0] +
vector.yp * matrix.m[0][1] +
vector.zp * matrix.m[0][2] +
@@ -680,7 +679,7 @@ inline QVector4D operator*(const QVector4D& vector, const QMatrix4x4& matrix)
inline QVector4D operator*(const QMatrix4x4& matrix, const QVector4D& vector)
{
- qrealinner x, y, z, w;
+ float x, y, z, w;
x = vector.xp * matrix.m[0][0] +
vector.yp * matrix.m[1][0] +
vector.zp * matrix.m[2][0] +
@@ -704,8 +703,8 @@ inline QVector4D operator*(const QMatrix4x4& matrix, const QVector4D& vector)
inline QPoint operator*(const QPoint& point, const QMatrix4x4& matrix)
{
- qrealinner xin, yin;
- qrealinner x, y, w;
+ float xin, yin;
+ float x, y, w;
xin = point.x();
yin = point.y();
x = xin * matrix.m[0][0] +
@@ -725,8 +724,8 @@ inline QPoint operator*(const QPoint& point, const QMatrix4x4& matrix)
inline QPointF operator*(const QPointF& point, const QMatrix4x4& matrix)
{
- qrealinner xin, yin;
- qrealinner x, y, w;
+ float xin, yin;
+ float x, y, w;
xin = point.x();
yin = point.y();
x = xin * matrix.m[0][0] +
@@ -739,18 +738,16 @@ inline QPointF operator*(const QPointF& point, const QMatrix4x4& matrix)
yin * matrix.m[3][1] +
matrix.m[3][3];
if (w == 1.0f) {
- return QPointF(qt_math3d_convert<qreal, qrealinner>(x),
- qt_math3d_convert<qreal, qrealinner>(y));
+ return QPointF(qreal(x), qreal(y));
} else {
- return QPointF(qt_math3d_convert<qreal, qrealinner>(x / w),
- qt_math3d_convert<qreal, qrealinner>(y / w));
+ return QPointF(qreal(x / w), qreal(y / w));
}
}
inline QPoint operator*(const QMatrix4x4& matrix, const QPoint& point)
{
- qrealinner xin, yin;
- qrealinner x, y, w;
+ float xin, yin;
+ float x, y, w;
xin = point.x();
yin = point.y();
x = xin * matrix.m[0][0] +
@@ -770,8 +767,8 @@ inline QPoint operator*(const QMatrix4x4& matrix, const QPoint& point)
inline QPointF operator*(const QMatrix4x4& matrix, const QPointF& point)
{
- qrealinner xin, yin;
- qrealinner x, y, w;
+ float xin, yin;
+ float x, y, w;
xin = point.x();
yin = point.y();
x = xin * matrix.m[0][0] +
@@ -784,11 +781,9 @@ inline QPointF operator*(const QMatrix4x4& matrix, const QPointF& point)
yin * matrix.m[1][3] +
matrix.m[3][3];
if (w == 1.0f) {
- return QPointF(qt_math3d_convert<qreal, qrealinner>(x),
- qt_math3d_convert<qreal, qrealinner>(y));
+ return QPointF(qreal(x), qreal(y));
} else {
- return QPointF(qt_math3d_convert<qreal, qrealinner>(x / w),
- qt_math3d_convert<qreal, qrealinner>(y / w));
+ return QPointF(qreal(x / w), qreal(y / w));
}
}
@@ -817,46 +812,44 @@ inline QMatrix4x4 operator-(const QMatrix4x4& matrix)
inline QMatrix4x4 operator*(qreal factor, const QMatrix4x4& matrix)
{
QMatrix4x4 m(1);
- qrealinner f(factor);
- m.m[0][0] = matrix.m[0][0] * f;
- m.m[0][1] = matrix.m[0][1] * f;
- m.m[0][2] = matrix.m[0][2] * f;
- m.m[0][3] = matrix.m[0][3] * f;
- m.m[1][0] = matrix.m[1][0] * f;
- m.m[1][1] = matrix.m[1][1] * f;
- m.m[1][2] = matrix.m[1][2] * f;
- m.m[1][3] = matrix.m[1][3] * f;
- m.m[2][0] = matrix.m[2][0] * f;
- m.m[2][1] = matrix.m[2][1] * f;
- m.m[2][2] = matrix.m[2][2] * f;
- m.m[2][3] = matrix.m[2][3] * f;
- m.m[3][0] = matrix.m[3][0] * f;
- m.m[3][1] = matrix.m[3][1] * f;
- m.m[3][2] = matrix.m[3][2] * f;
- m.m[3][3] = matrix.m[3][3] * f;
+ m.m[0][0] = matrix.m[0][0] * factor;
+ m.m[0][1] = matrix.m[0][1] * factor;
+ m.m[0][2] = matrix.m[0][2] * factor;
+ m.m[0][3] = matrix.m[0][3] * factor;
+ m.m[1][0] = matrix.m[1][0] * factor;
+ m.m[1][1] = matrix.m[1][1] * factor;
+ m.m[1][2] = matrix.m[1][2] * factor;
+ m.m[1][3] = matrix.m[1][3] * factor;
+ m.m[2][0] = matrix.m[2][0] * factor;
+ m.m[2][1] = matrix.m[2][1] * factor;
+ m.m[2][2] = matrix.m[2][2] * factor;
+ m.m[2][3] = matrix.m[2][3] * factor;
+ m.m[3][0] = matrix.m[3][0] * factor;
+ m.m[3][1] = matrix.m[3][1] * factor;
+ m.m[3][2] = matrix.m[3][2] * factor;
+ m.m[3][3] = matrix.m[3][3] * factor;
return m;
}
inline QMatrix4x4 operator*(const QMatrix4x4& matrix, qreal factor)
{
QMatrix4x4 m(1);
- qrealinner f(factor);
- m.m[0][0] = matrix.m[0][0] * f;
- m.m[0][1] = matrix.m[0][1] * f;
- m.m[0][2] = matrix.m[0][2] * f;
- m.m[0][3] = matrix.m[0][3] * f;
- m.m[1][0] = matrix.m[1][0] * f;
- m.m[1][1] = matrix.m[1][1] * f;
- m.m[1][2] = matrix.m[1][2] * f;
- m.m[1][3] = matrix.m[1][3] * f;
- m.m[2][0] = matrix.m[2][0] * f;
- m.m[2][1] = matrix.m[2][1] * f;
- m.m[2][2] = matrix.m[2][2] * f;
- m.m[2][3] = matrix.m[2][3] * f;
- m.m[3][0] = matrix.m[3][0] * f;
- m.m[3][1] = matrix.m[3][1] * f;
- m.m[3][2] = matrix.m[3][2] * f;
- m.m[3][3] = matrix.m[3][3] * f;
+ m.m[0][0] = matrix.m[0][0] * factor;
+ m.m[0][1] = matrix.m[0][1] * factor;
+ m.m[0][2] = matrix.m[0][2] * factor;
+ m.m[0][3] = matrix.m[0][3] * factor;
+ m.m[1][0] = matrix.m[1][0] * factor;
+ m.m[1][1] = matrix.m[1][1] * factor;
+ m.m[1][2] = matrix.m[1][2] * factor;
+ m.m[1][3] = matrix.m[1][3] * factor;
+ m.m[2][0] = matrix.m[2][0] * factor;
+ m.m[2][1] = matrix.m[2][1] * factor;
+ m.m[2][2] = matrix.m[2][2] * factor;
+ m.m[2][3] = matrix.m[2][3] * factor;
+ m.m[3][0] = matrix.m[3][0] * factor;
+ m.m[3][1] = matrix.m[3][1] * factor;
+ m.m[3][2] = matrix.m[3][2] * factor;
+ m.m[3][3] = matrix.m[3][3] * factor;
return m;
}
@@ -934,7 +927,7 @@ inline QRectF QMatrix4x4::mapRect(const QRectF& rect) const
return QRectF(QPointF(xmin, ymin), QPointF(xmax, ymax));
}
-inline qrealinner *QMatrix4x4::data()
+inline float *QMatrix4x4::data()
{
// We have to assume that the caller will modify the matrix elements,
// so we flip it over to "General" mode.
@@ -947,17 +940,17 @@ Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QMatrix4x4 &m);
#endif
template <int N, int M>
-QMatrix4x4 qGenericMatrixToMatrix4x4(const QGenericMatrix<N, M, qreal, qrealinner>& matrix)
+QMatrix4x4 qGenericMatrixToMatrix4x4(const QGenericMatrix<N, M, qreal, float>& matrix)
{
return QMatrix4x4(matrix.constData(), N, M);
}
template <int N, int M>
-QGenericMatrix<N, M, qreal, qrealinner> qGenericMatrixFromMatrix4x4(const QMatrix4x4& matrix)
+QGenericMatrix<N, M, qreal, float> qGenericMatrixFromMatrix4x4(const QMatrix4x4& matrix)
{
- QGenericMatrix<N, M, qreal, qrealinner> result;
- const qrealinner *m = matrix.constData();
- qrealinner *values = result.data();
+ QGenericMatrix<N, M, qreal, float> result;
+ const float *m = matrix.constData();
+ float *values = result.data();
for (int col = 0; col < N; ++col) {
for (int row = 0; row < M; ++row) {
if (col < 4 && row < 4)
diff --git a/src/gui/math3d/qquaternion.cpp b/src/gui/math3d/qquaternion.cpp
index 121ff51..efde362 100644
--- a/src/gui/math3d/qquaternion.cpp
+++ b/src/gui/math3d/qquaternion.cpp
@@ -40,8 +40,8 @@
****************************************************************************/
#include "qquaternion.h"
-#include "qmath3dutil_p.h"
#include <QtCore/qmath.h>
+#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
@@ -223,8 +223,7 @@ QT_BEGIN_NAMESPACE
*/
qreal QQuaternion::length() const
{
- return qvtsqrt64(qvtmul64(xp, xp) + qvtmul64(yp, yp) +
- qvtmul64(zp, zp) + qvtmul64(wp, wp));
+ return qSqrt(xp * xp + yp * yp + zp * zp + wp * wp);
}
/*!
@@ -234,8 +233,7 @@ qreal QQuaternion::length() const
*/
qreal QQuaternion::lengthSquared() const
{
- return qvtdot64(qvtmul64(xp, xp) + qvtmul64(yp, yp) +
- qvtmul64(zp, zp) + qvtmul64(wp, wp));
+ return xp * xp + yp * yp + zp * zp + wp * wp;
}
/*!
@@ -342,6 +340,10 @@ QVector3D QQuaternion::rotateVector(const QVector3D& vector) const
\sa operator*=()
*/
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
#ifndef QT_NO_VECTOR3D
/*!
@@ -354,9 +356,10 @@ QQuaternion QQuaternion::fromAxisAndAngle(const QVector3D& axis, qreal angle)
// http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q56
// We normalize the result just in case the values are close
// to zero, as suggested in the above FAQ.
- qrealinner s, c;
+ qreal a = (angle / 2.0f) * M_PI / 180.0f;
+ qreal s = qSin(a);
+ qreal c = qCos(a);
QVector3D ax = axis.normalized();
- qt_math3d_sincos(angle / 2.0f, &s, &c);
return QQuaternion(c, ax.xp * s, ax.yp * s, ax.zp * s, 1).normalized();
}
@@ -369,17 +372,18 @@ QQuaternion QQuaternion::fromAxisAndAngle(const QVector3D& axis, qreal angle)
QQuaternion QQuaternion::fromAxisAndAngle
(qreal x, qreal y, qreal z, qreal angle)
{
- qrealinner xp = x;
- qrealinner yp = y;
- qrealinner zp = z;
- qrealinner s, c;
- qreal length = qvtsqrt(xp * xp + yp * yp + zp * zp);
+ float xp = x;
+ float yp = y;
+ float zp = z;
+ qreal length = qSqrt(xp * xp + yp * yp + zp * zp);
if (!qIsNull(length)) {
xp /= length;
yp /= length;
zp /= length;
}
- qt_math3d_sincos(angle / 2.0f, &s, &c);
+ qreal a = (angle / 2.0f) * M_PI / 180.0f;
+ qreal s = qSin(a);
+ qreal c = qCos(a);
return QQuaternion(c, xp * s, yp * s, zp * s, 1).normalized();
}
@@ -500,8 +504,7 @@ QQuaternion QQuaternion::interpolate
// Determine the angle between the two quaternions.
QQuaternion q2b;
qreal dot;
- dot = qvtdot64(qvtmul64(q1.xp, q2.xp) + qvtmul64(q1.yp, q2.yp) +
- qvtmul64(q1.zp, q2.zp) + qvtmul64(q1.wp, q2.wp));
+ dot = q1.xp * q2.xp + q1.yp * q2.yp + q1.zp * q2.zp + q1.wp * q2.wp;
if (dot >= 0.0f) {
q2b = q2;
} else {
diff --git a/src/gui/math3d/qquaternion.h b/src/gui/math3d/qquaternion.h
index 6ba63ec..f0cb308 100644
--- a/src/gui/math3d/qquaternion.h
+++ b/src/gui/math3d/qquaternion.h
@@ -129,11 +129,11 @@ public:
(const QQuaternion& q1, const QQuaternion& q2, qreal t);
private:
- qrealinner wp, xp, yp, zp;
+ float wp, xp, yp, zp;
friend class QMatrix4x4;
- QQuaternion(qrealinner scalar, qrealinner xpos, qrealinner ypos, qrealinner zpos, int dummy);
+ QQuaternion(float scalar, float xpos, float ypos, float zpos, int dummy);
};
inline QQuaternion::QQuaternion() : wp(1.0f), xp(0.0f), yp(0.0f), zp(0.0f) {}
@@ -141,7 +141,7 @@ inline QQuaternion::QQuaternion() : wp(1.0f), xp(0.0f), yp(0.0f), zp(0.0f) {}
inline QQuaternion::QQuaternion(qreal scalar, qreal xpos, qreal ypos, qreal zpos) : wp(scalar), xp(xpos), yp(ypos), zp(zpos) {}
-inline QQuaternion::QQuaternion(qrealinner scalar, qrealinner xpos, qrealinner ypos, qrealinner zpos, int) : wp(scalar), xp(xpos), yp(ypos), zp(zpos) {}
+inline QQuaternion::QQuaternion(float scalar, float xpos, float ypos, float zpos, int) : wp(scalar), xp(xpos), yp(ypos), zp(zpos) {}
inline QQuaternion::QQuaternion(int scalar, int xpos, int ypos, int zpos) : wp(scalar), xp(xpos), yp(ypos), zp(zpos) {}
@@ -155,10 +155,10 @@ inline bool QQuaternion::isIdentity() const
return qIsNull(xp) && qIsNull(yp) && qIsNull(zp) && wp == 1.0f;
}
-inline qreal QQuaternion::x() const { return qt_math3d_convert<qreal, qrealinner>(xp); }
-inline qreal QQuaternion::y() const { return qt_math3d_convert<qreal, qrealinner>(yp); }
-inline qreal QQuaternion::z() const { return qt_math3d_convert<qreal, qrealinner>(zp); }
-inline qreal QQuaternion::scalar() const { return qt_math3d_convert<qreal, qrealinner>(wp); }
+inline qreal QQuaternion::x() const { return qreal(xp); }
+inline qreal QQuaternion::y() const { return qreal(yp); }
+inline qreal QQuaternion::z() const { return qreal(zp); }
+inline qreal QQuaternion::scalar() const { return qreal(wp); }
inline void QQuaternion::setX(qreal x) { xp = x; }
inline void QQuaternion::setY(qreal y) { yp = y; }
@@ -190,11 +190,10 @@ inline QQuaternion &QQuaternion::operator-=(const QQuaternion &quaternion)
inline QQuaternion &QQuaternion::operator*=(qreal factor)
{
- qrealinner f(factor);
- xp *= f;
- yp *= f;
- zp *= f;
- wp *= f;
+ xp *= factor;
+ yp *= factor;
+ zp *= factor;
+ wp *= factor;
return *this;
}
@@ -202,19 +201,19 @@ inline const QQuaternion operator*(const QQuaternion &q1, const QQuaternion& q2)
{
// Algorithm from:
// http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q53
- qrealinner x = q1.wp * q2.xp +
+ float x = q1.wp * q2.xp +
q1.xp * q2.wp +
q1.yp * q2.zp -
q1.zp * q2.yp;
- qrealinner y = q1.wp * q2.yp +
+ float y = q1.wp * q2.yp +
q1.yp * q2.wp +
q1.zp * q2.xp -
q1.xp * q2.zp;
- qrealinner z = q1.wp * q2.zp +
+ float z = q1.wp * q2.zp +
q1.zp * q2.wp +
q1.xp * q2.yp -
q1.yp * q2.xp;
- qrealinner w = q1.wp * q2.wp -
+ float w = q1.wp * q2.wp -
q1.xp * q2.xp -
q1.yp * q2.yp -
q1.zp * q2.zp;
@@ -229,11 +228,10 @@ inline QQuaternion &QQuaternion::operator*=(const QQuaternion &quaternion)
inline QQuaternion &QQuaternion::operator/=(qreal divisor)
{
- qrealinner d(divisor);
- xp /= d;
- yp /= d;
- zp /= d;
- wp /= d;
+ xp /= divisor;
+ yp /= divisor;
+ zp /= divisor;
+ wp /= divisor;
return *this;
}
@@ -259,14 +257,12 @@ inline const QQuaternion operator-(const QQuaternion &q1, const QQuaternion &q2)
inline const QQuaternion operator*(qreal factor, const QQuaternion &quaternion)
{
- qrealinner f(factor);
- return QQuaternion(quaternion.wp * f, quaternion.xp * f, quaternion.yp * f, quaternion.zp * f, 1);
+ return QQuaternion(quaternion.wp * factor, quaternion.xp * factor, quaternion.yp * factor, quaternion.zp * factor, 1);
}
inline const QQuaternion operator*(const QQuaternion &quaternion, qreal factor)
{
- qrealinner f(factor);
- return QQuaternion(quaternion.wp * f, quaternion.xp * f, quaternion.yp * f, quaternion.zp * f, 1);
+ return QQuaternion(quaternion.wp * factor, quaternion.xp * factor, quaternion.yp * factor, quaternion.zp * factor, 1);
}
inline const QQuaternion operator-(const QQuaternion &quaternion)
@@ -276,8 +272,7 @@ inline const QQuaternion operator-(const QQuaternion &quaternion)
inline const QQuaternion operator/(const QQuaternion &quaternion, qreal divisor)
{
- qrealinner d(divisor);
- return QQuaternion(quaternion.wp / d, quaternion.xp / d, quaternion.yp / d, quaternion.zp / d, 1);
+ return QQuaternion(quaternion.wp / divisor, quaternion.xp / divisor, quaternion.yp / divisor, quaternion.zp / divisor, 1);
}
inline bool qFuzzyCompare(const QQuaternion& q1, const QQuaternion& q2)
diff --git a/src/gui/math3d/qvector2d.cpp b/src/gui/math3d/qvector2d.cpp
index 0426fc5..31e5be6 100644
--- a/src/gui/math3d/qvector2d.cpp
+++ b/src/gui/math3d/qvector2d.cpp
@@ -42,7 +42,8 @@
#include "qvector2d.h"
#include "qvector3d.h"
#include "qvector4d.h"
-#include "qmath3dutil_p.h"
+#include <QtCore/qdebug.h>
+#include <QtCore/qmath.h>
QT_BEGIN_NAMESPACE
@@ -169,7 +170,7 @@ QVector2D::QVector2D(const QVector4D& vector)
*/
qreal QVector2D::length() const
{
- return qvtsqrt64(qvtmul64(xp, xp) + qvtmul64(yp, yp));
+ return qSqrt(xp * xp + yp * yp);
}
/*!
@@ -180,7 +181,7 @@ qreal QVector2D::length() const
*/
qreal QVector2D::lengthSquared() const
{
- return qvtdot64(qvtmul64(xp, xp) + qvtmul64(yp, yp));
+ return xp * xp + yp * yp;
}
/*!
@@ -263,7 +264,7 @@ void QVector2D::normalize()
*/
qreal QVector2D::dotProduct(const QVector2D& v1, const QVector2D& v2)
{
- return qvtdot64(qvtmul64(v1.xp, v2.xp) + qvtmul64(v1.yp, v2.yp));
+ return v1.xp * v2.xp + v1.yp * v2.yp;
}
/*!
diff --git a/src/gui/math3d/qvector2d.h b/src/gui/math3d/qvector2d.h
index a72ecc5..5e15de6 100644
--- a/src/gui/math3d/qvector2d.h
+++ b/src/gui/math3d/qvector2d.h
@@ -42,7 +42,6 @@
#ifndef QVECTOR2D_H
#define QVECTOR2D_H
-#include <QtGui/qmath3dglobal.h>
#include <QtCore/qpoint.h>
#include <QtCore/qmetatype.h>
@@ -117,18 +116,17 @@ public:
QPointF toPointF() const;
private:
- qrealinner xp, yp;
+ float xp, yp;
- QVector2D(qrealinner xpos, qrealinner ypos, int dummy);
+ QVector2D(float xpos, float ypos, int dummy);
friend class QVector3D;
friend class QVector4D;
- friend class QVertexArray;
};
inline QVector2D::QVector2D() : xp(0.0f), yp(0.0f) {}
-inline QVector2D::QVector2D(qrealinner xpos, qrealinner ypos, int) : xp(xpos), yp(ypos) {}
+inline QVector2D::QVector2D(float xpos, float ypos, int) : xp(xpos), yp(ypos) {}
inline QVector2D::QVector2D(qreal xpos, qreal ypos) : xp(xpos), yp(ypos) {}
@@ -143,8 +141,8 @@ inline bool QVector2D::isNull() const
return qIsNull(xp) && qIsNull(yp);
}
-inline qreal QVector2D::x() const { return qt_math3d_convert<qreal, qrealinner>(xp); }
-inline qreal QVector2D::y() const { return qt_math3d_convert<qreal, qrealinner>(yp); }
+inline qreal QVector2D::x() const { return qreal(xp); }
+inline qreal QVector2D::y() const { return qreal(yp); }
inline void QVector2D::setX(qreal x) { xp = x; }
inline void QVector2D::setY(qreal y) { yp = y; }
@@ -165,9 +163,8 @@ inline QVector2D &QVector2D::operator-=(const QVector2D &vector)
inline QVector2D &QVector2D::operator*=(qreal factor)
{
- qrealinner f(factor);
- xp *= f;
- yp *= f;
+ xp *= factor;
+ yp *= factor;
return *this;
}
@@ -180,9 +177,8 @@ inline QVector2D &QVector2D::operator*=(const QVector2D &vector)
inline QVector2D &QVector2D::operator/=(qreal divisor)
{
- qrealinner d(divisor);
- xp /= d;
- yp /= d;
+ xp /= divisor;
+ yp /= divisor;
return *this;
}
@@ -208,14 +204,12 @@ inline const QVector2D operator-(const QVector2D &v1, const QVector2D &v2)
inline const QVector2D operator*(qreal factor, const QVector2D &vector)
{
- qrealinner f(factor);
- return QVector2D(vector.xp * f, vector.yp * f, 1);
+ return QVector2D(vector.xp * factor, vector.yp * factor, 1);
}
inline const QVector2D operator*(const QVector2D &vector, qreal factor)
{
- qrealinner f(factor);
- return QVector2D(vector.xp * f, vector.yp * f, 1);
+ return QVector2D(vector.xp * factor, vector.yp * factor, 1);
}
inline const QVector2D operator*(const QVector2D &v1, const QVector2D &v2)
@@ -230,8 +224,7 @@ inline const QVector2D operator-(const QVector2D &vector)
inline const QVector2D operator/(const QVector2D &vector, qreal divisor)
{
- qrealinner d(divisor);
- return QVector2D(vector.xp / d, vector.yp / d, 1);
+ return QVector2D(vector.xp / divisor, vector.yp / divisor, 1);
}
inline bool qFuzzyCompare(const QVector2D& v1, const QVector2D& v2)
@@ -246,8 +239,7 @@ inline QPoint QVector2D::toPoint() const
inline QPointF QVector2D::toPointF() const
{
- return QPointF(qt_math3d_convert<qreal, qrealinner>(xp),
- qt_math3d_convert<qreal, qrealinner>(yp));
+ return QPointF(qreal(xp), qreal(yp));
}
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/gui/math3d/qvector3d.cpp b/src/gui/math3d/qvector3d.cpp
index 32068ee..814753d 100644
--- a/src/gui/math3d/qvector3d.cpp
+++ b/src/gui/math3d/qvector3d.cpp
@@ -42,8 +42,8 @@
#include "qvector3d.h"
#include "qvector2d.h"
#include "qvector4d.h"
-#include "qmath3dutil_p.h"
#include <QtCore/qmath.h>
+#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
@@ -287,7 +287,7 @@ void QVector3D::normalize()
*/
qreal QVector3D::dotProduct(const QVector3D& v1, const QVector3D& v2)
{
- return qvtdot64(qvtmul64(v1.xp, v2.xp) + qvtmul64(v1.yp, v2.yp) + qvtmul64(v1.zp, v2.zp));
+ return v1.xp * v2.xp + v1.yp * v2.yp + v1.zp * v2.zp;
}
/*!
@@ -535,7 +535,7 @@ QVector4D QVector3D::toVector4D() const
*/
qreal QVector3D::length() const
{
- return qvtsqrt64(qvtmul64(xp, xp) + qvtmul64(yp, yp) + qvtmul64(zp, zp));
+ return qSqrt(xp * xp + yp * yp + zp * zp);
}
/*!
@@ -546,7 +546,7 @@ qreal QVector3D::length() const
*/
qreal QVector3D::lengthSquared() const
{
- return qvtdot64(qvtmul64(xp, xp) + qvtmul64(yp, yp) + qvtmul64(zp, zp));
+ return xp * xp + yp * yp + zp * zp;
}
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/gui/math3d/qvector3d.h b/src/gui/math3d/qvector3d.h
index 8f8f3b4..4771d5a 100644
--- a/src/gui/math3d/qvector3d.h
+++ b/src/gui/math3d/qvector3d.h
@@ -42,7 +42,6 @@
#ifndef QVECTOR3D_H
#define QVECTOR3D_H
-#include <QtGui/qmath3dglobal.h>
#include <QtCore/qpoint.h>
#include <QtCore/qmetatype.h>
@@ -130,16 +129,14 @@ public:
QPointF toPointF() const;
private:
- qrealinner xp, yp, zp;
+ float xp, yp, zp;
- QVector3D(qrealinner xpos, qrealinner ypos, qrealinner zpos, int dummy);
+ QVector3D(float xpos, float ypos, float zpos, int dummy);
friend class QVector2D;
friend class QVector4D;
friend class QQuaternion;
friend class QMatrix4x4;
- friend class QVertexArray;
- friend class QGLPainter;
#ifndef QT_NO_MATRIX4X4
friend QVector3D operator*(const QVector3D& vector, const QMatrix4x4& matrix);
friend QVector3D operator*(const QMatrix4x4& matrix, const QVector3D& vector);
@@ -150,7 +147,7 @@ inline QVector3D::QVector3D() : xp(0.0f), yp(0.0f), zp(0.0f) {}
inline QVector3D::QVector3D(qreal xpos, qreal ypos, qreal zpos) : xp(xpos), yp(ypos), zp(zpos) {}
-inline QVector3D::QVector3D(qrealinner xpos, qrealinner ypos, qrealinner zpos, int) : xp(xpos), yp(ypos), zp(zpos) {}
+inline QVector3D::QVector3D(float xpos, float ypos, float zpos, int) : xp(xpos), yp(ypos), zp(zpos) {}
inline QVector3D::QVector3D(int xpos, int ypos, int zpos) : xp(xpos), yp(ypos), zp(zpos) {}
@@ -163,9 +160,9 @@ inline bool QVector3D::isNull() const
return qIsNull(xp) && qIsNull(yp) && qIsNull(zp);
}
-inline qreal QVector3D::x() const { return qt_math3d_convert<qreal, qrealinner>(xp); }
-inline qreal QVector3D::y() const { return qt_math3d_convert<qreal, qrealinner>(yp); }
-inline qreal QVector3D::z() const { return qt_math3d_convert<qreal, qrealinner>(zp); }
+inline qreal QVector3D::x() const { return qreal(xp); }
+inline qreal QVector3D::y() const { return qreal(yp); }
+inline qreal QVector3D::z() const { return qreal(zp); }
inline void QVector3D::setX(qreal x) { xp = x; }
inline void QVector3D::setY(qreal y) { yp = y; }
@@ -189,10 +186,9 @@ inline QVector3D &QVector3D::operator-=(const QVector3D &vector)
inline QVector3D &QVector3D::operator*=(qreal factor)
{
- qrealinner f(factor);
- xp *= f;
- yp *= f;
- zp *= f;
+ xp *= factor;
+ yp *= factor;
+ zp *= factor;
return *this;
}
@@ -206,10 +202,9 @@ inline QVector3D &QVector3D::operator*=(const QVector3D& vector)
inline QVector3D &QVector3D::operator/=(qreal divisor)
{
- qrealinner d(divisor);
- xp /= d;
- yp /= d;
- zp /= d;
+ xp /= divisor;
+ yp /= divisor;
+ zp /= divisor;
return *this;
}
@@ -235,14 +230,12 @@ inline const QVector3D operator-(const QVector3D &v1, const QVector3D &v2)
inline const QVector3D operator*(qreal factor, const QVector3D &vector)
{
- qrealinner f(factor);
- return QVector3D(vector.xp * f, vector.yp * f, vector.zp * f, 1);
+ return QVector3D(vector.xp * factor, vector.yp * factor, vector.zp * factor, 1);
}
inline const QVector3D operator*(const QVector3D &vector, qreal factor)
{
- qrealinner f(factor);
- return QVector3D(vector.xp * f, vector.yp * f, vector.zp * f, 1);
+ return QVector3D(vector.xp * factor, vector.yp * factor, vector.zp * factor, 1);
}
inline const QVector3D operator*(const QVector3D &v1, const QVector3D& v2)
@@ -257,8 +250,7 @@ inline const QVector3D operator-(const QVector3D &vector)
inline const QVector3D operator/(const QVector3D &vector, qreal divisor)
{
- qrealinner d(divisor);
- return QVector3D(vector.xp / d, vector.yp / d, vector.zp / d, 1);
+ return QVector3D(vector.xp / divisor, vector.yp / divisor, vector.zp / divisor, 1);
}
inline bool qFuzzyCompare(const QVector3D& v1, const QVector3D& v2)
@@ -275,8 +267,7 @@ inline QPoint QVector3D::toPoint() const
inline QPointF QVector3D::toPointF() const
{
- return QPointF(qt_math3d_convert<qreal, qrealinner>(xp),
- qt_math3d_convert<qreal, qrealinner>(yp));
+ return QPointF(qreal(xp), qreal(yp));
}
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/gui/math3d/qvector4d.cpp b/src/gui/math3d/qvector4d.cpp
index 4287806..d19665a 100644
--- a/src/gui/math3d/qvector4d.cpp
+++ b/src/gui/math3d/qvector4d.cpp
@@ -42,7 +42,8 @@
#include "qvector4d.h"
#include "qvector3d.h"
#include "qvector2d.h"
-#include "qmath3dutil_p.h"
+#include <QtCore/qdebug.h>
+#include <QtCore/qmath.h>
QT_BEGIN_NAMESPACE
@@ -237,8 +238,7 @@ QVector4D::QVector4D(const QVector3D& vector, qreal wpos)
*/
qreal QVector4D::length() const
{
- return qvtsqrt64(qvtmul64(xp, xp) + qvtmul64(yp, yp) +
- qvtmul64(zp, zp) + qvtmul64(wp, wp));
+ return qSqrt(xp * xp + yp * yp + zp * zp + wp * wp);
}
/*!
@@ -249,8 +249,7 @@ qreal QVector4D::length() const
*/
qreal QVector4D::lengthSquared() const
{
- return qvtdot64(qvtmul64(xp, xp) + qvtmul64(yp, yp) +
- qvtmul64(zp, zp) + qvtmul64(wp, wp));
+ return xp * xp + yp * yp + zp * zp + wp * wp;
}
/*!
@@ -336,8 +335,7 @@ void QVector4D::normalize()
*/
qreal QVector4D::dotProduct(const QVector4D& v1, const QVector4D& v2)
{
- return qvtdot64(qvtmul64(v1.xp, v2.xp) + qvtmul64(v1.yp, v2.yp) +
- qvtmul64(v1.zp, v2.zp) + qvtmul64(v1.wp, v2.wp));
+ return v1.xp * v2.xp + v1.yp * v2.yp + v1.zp * v2.zp + v1.wp * v2.wp;
}
/*!
diff --git a/src/gui/math3d/qvector4d.h b/src/gui/math3d/qvector4d.h
index 4ac6ae8..12efc95 100644
--- a/src/gui/math3d/qvector4d.h
+++ b/src/gui/math3d/qvector4d.h
@@ -42,7 +42,6 @@
#ifndef QVECTOR4D_H
#define QVECTOR4D_H
-#include <QtGui/qmath3dglobal.h>
#include <QtCore/qpoint.h>
#include <QtCore/qmetatype.h>
@@ -127,15 +126,14 @@ public:
QPointF toPointF() const;
private:
- qrealinner xp, yp, zp, wp;
+ float xp, yp, zp, wp;
- QVector4D(qrealinner xpos, qrealinner ypos, qrealinner zpos, qrealinner wpos, int dummy);
+ QVector4D(float xpos, float ypos, float zpos, float wpos, int dummy);
friend class QVector2D;
friend class QVector3D;
friend class QQuaternion;
friend class QMatrix4x4;
- friend class QVertexArray;
#ifndef QT_NO_MATRIX4X4
friend QVector4D operator*(const QVector4D& vector, const QMatrix4x4& matrix);
friend QVector4D operator*(const QMatrix4x4& matrix, const QVector4D& vector);
@@ -146,7 +144,7 @@ inline QVector4D::QVector4D() : xp(0.0f), yp(0.0f), zp(0.0f), wp(0.0f) {}
inline QVector4D::QVector4D(qreal xpos, qreal ypos, qreal zpos, qreal wpos) : xp(xpos), yp(ypos), zp(zpos), wp(wpos) {}
-inline QVector4D::QVector4D(qrealinner xpos, qrealinner ypos, qrealinner zpos, qrealinner wpos, int) : xp(xpos), yp(ypos), zp(zpos), wp(wpos) {}
+inline QVector4D::QVector4D(float xpos, float ypos, float zpos, float wpos, int) : xp(xpos), yp(ypos), zp(zpos), wp(wpos) {}
inline QVector4D::QVector4D(int xpos, int ypos, int zpos, int wpos) : xp(xpos), yp(ypos), zp(zpos), wp(wpos) {}
@@ -159,10 +157,10 @@ inline bool QVector4D::isNull() const
return qIsNull(xp) && qIsNull(yp) && qIsNull(zp) && qIsNull(wp);
}
-inline qreal QVector4D::x() const { return qt_math3d_convert<qreal, qrealinner>(xp); }
-inline qreal QVector4D::y() const { return qt_math3d_convert<qreal, qrealinner>(yp); }
-inline qreal QVector4D::z() const { return qt_math3d_convert<qreal, qrealinner>(zp); }
-inline qreal QVector4D::w() const { return qt_math3d_convert<qreal, qrealinner>(wp); }
+inline qreal QVector4D::x() const { return qreal(xp); }
+inline qreal QVector4D::y() const { return qreal(yp); }
+inline qreal QVector4D::z() const { return qreal(zp); }
+inline qreal QVector4D::w() const { return qreal(wp); }
inline void QVector4D::setX(qreal x) { xp = x; }
inline void QVector4D::setY(qreal y) { yp = y; }
@@ -189,11 +187,10 @@ inline QVector4D &QVector4D::operator-=(const QVector4D &vector)
inline QVector4D &QVector4D::operator*=(qreal factor)
{
- qrealinner f(factor);
- xp *= f;
- yp *= f;
- zp *= f;
- wp *= f;
+ xp *= factor;
+ yp *= factor;
+ zp *= factor;
+ wp *= factor;
return *this;
}
@@ -208,11 +205,10 @@ inline QVector4D &QVector4D::operator*=(const QVector4D &vector)
inline QVector4D &QVector4D::operator/=(qreal divisor)
{
- qrealinner d(divisor);
- xp /= d;
- yp /= d;
- zp /= d;
- wp /= d;
+ xp /= divisor;
+ yp /= divisor;
+ zp /= divisor;
+ wp /= divisor;
return *this;
}
@@ -238,14 +234,12 @@ inline const QVector4D operator-(const QVector4D &v1, const QVector4D &v2)
inline const QVector4D operator*(qreal factor, const QVector4D &vector)
{
- qrealinner f(factor);
- return QVector4D(vector.xp * f, vector.yp * f, vector.zp * f, vector.wp * f, 1);
+ return QVector4D(vector.xp * factor, vector.yp * factor, vector.zp * factor, vector.wp * factor, 1);
}
inline const QVector4D operator*(const QVector4D &vector, qreal factor)
{
- qrealinner f(factor);
- return QVector4D(vector.xp * f, vector.yp * f, vector.zp * f, vector.wp * f, 1);
+ return QVector4D(vector.xp * factor, vector.yp * factor, vector.zp * factor, vector.wp * factor, 1);
}
inline const QVector4D operator*(const QVector4D &v1, const QVector4D& v2)
@@ -260,8 +254,7 @@ inline const QVector4D operator-(const QVector4D &vector)
inline const QVector4D operator/(const QVector4D &vector, qreal divisor)
{
- qrealinner d(divisor);
- return QVector4D(vector.xp / d, vector.yp / d, vector.zp / d, vector.wp / d, 1);
+ return QVector4D(vector.xp / divisor, vector.yp / divisor, vector.zp / divisor, vector.wp / divisor, 1);
}
inline bool qFuzzyCompare(const QVector4D& v1, const QVector4D& v2)
@@ -279,8 +272,7 @@ inline QPoint QVector4D::toPoint() const
inline QPointF QVector4D::toPointF() const
{
- return QPointF(qt_math3d_convert<qreal, qrealinner>(xp),
- qt_math3d_convert<qreal, qrealinner>(yp));
+ return QPointF(qreal(xp), qreal(yp));
}
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/gui/painting/qbezier.cpp b/src/gui/painting/qbezier.cpp
index 8317dd8..7ed521e 100644
--- a/src/gui/painting/qbezier.cpp
+++ b/src/gui/painting/qbezier.cpp
@@ -127,13 +127,13 @@ static inline void flattenBezierWithoutInflections(QBezier &bez,
qreal dy = bez.y2 - bez.y1;
qreal normalized = qSqrt(dx * dx + dy * dy);
- if (qFuzzyCompare(normalized + 1, 1))
+ if (qFuzzyIsNull(normalized))
break;
qreal d = qAbs(dx * (bez.y3 - bez.y2) - dy * (bez.x3 - bez.x2));
qreal t = qSqrt(4. / 3. * normalized * flatness / d);
- if (t > 1 || qFuzzyCompare(t, (qreal)1.))
+ if (t > 1 || qFuzzyIsNull(t - (qreal)1.))
break;
bez.parameterSplitLeft(t, &left);
p->append(bez.pt1());
@@ -144,19 +144,19 @@ static inline void flattenBezierWithoutInflections(QBezier &bez,
static inline int quadraticRoots(qreal a, qreal b, qreal c,
qreal *x1, qreal *x2)
{
- if (qFuzzyCompare(a + 1, 1)) {
- if (qFuzzyCompare(b + 1, 1))
+ if (qFuzzyIsNull(a)) {
+ if (qFuzzyIsNull(b))
return 0;
*x1 = *x2 = (-c / b);
return 1;
} else {
const qreal det = b * b - 4 * a * c;
- if (qFuzzyCompare(det + 1, 1)) {
+ if (qFuzzyIsNull(det)) {
*x1 = *x2 = -b / (2 * a);
return 1;
}
if (det > 0) {
- if (qFuzzyCompare(b + 1, 1)) {
+ if (qFuzzyIsNull(b)) {
*x2 = qSqrt(-c / a);
*x1 = -(*x2);
return 2;
@@ -187,7 +187,7 @@ static inline bool findInflections(qreal a, qreal b, qreal c,
*t1 = r2;
*t2 = r1;
}
- if (!qFuzzyCompare(a + 1, 1))
+ if (!qFuzzyIsNull(a))
*tCups = 0.5 * (-b / a);
else
*tCups = 2;
@@ -243,7 +243,7 @@ void QBezier::addToPolygonMixed(QPolygonF *polygon) const
qreal b = 6 * (ay * cx - ax * cy);
qreal c = 2 * (by * cx - bx * cy);
- if ((qFuzzyCompare(a + 1, 1) && qFuzzyCompare(b + 1, 1)) ||
+ if ((qFuzzyIsNull(a) && qFuzzyIsNull(b)) ||
(b * b - 4 * a *c) < 0) {
QBezier bez(*this);
flattenBezierWithoutInflections(bez, polygon);
@@ -447,7 +447,7 @@ static ShiftResult shift(const QBezier *orig, QBezier *shifted, qreal offset, qr
qreal r = 1.0 + prev_normal.x() * next_normal.x()
+ prev_normal.y() * next_normal.y();
- if (qFuzzyCompare(r + 1, 1)) {
+ if (qFuzzyIsNull(r)) {
points_shifted[i] = points[i] + offset * prev_normal;
} else {
qreal k = offset / r;
@@ -477,12 +477,12 @@ static bool addCircle(const QBezier *b, qreal offset, QBezier *o)
normals[0] = QPointF(b->y2 - b->y1, b->x1 - b->x2);
qreal dist = qSqrt(normals[0].x()*normals[0].x() + normals[0].y()*normals[0].y());
- if (qFuzzyCompare(dist + 1, 1))
+ if (qFuzzyIsNull(dist))
return false;
normals[0] /= dist;
normals[2] = QPointF(b->y4 - b->y3, b->x3 - b->x4);
dist = qSqrt(normals[2].x()*normals[2].x() + normals[2].y()*normals[2].y());
- if (qFuzzyCompare(dist + 1, 1))
+ if (qFuzzyIsNull(dist))
return false;
normals[2] /= dist;
@@ -1022,7 +1022,7 @@ int QBezier::stationaryYPoints(qreal &t0, qreal &t1) const
QList<qreal> result;
- if (qFuzzyCompare(reciprocal + 1, 1)) {
+ if (qFuzzyIsNull(reciprocal)) {
t0 = -b / (2 * a);
return 1;
} else if (reciprocal > 0) {
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp
index 5d7d4ab..24d167e 100644
--- a/src/gui/painting/qcolor.cpp
+++ b/src/gui/painting/qcolor.cpp
@@ -1387,7 +1387,7 @@ QColor QColor::toHsv() const
const qreal min = Q_MIN_3(r, g, b);
const qreal delta = max - min;
color.ct.ahsv.value = qRound(max * USHRT_MAX);
- if (qFuzzyCompare(delta + 1, 1)) {
+ if (qFuzzyIsNull(delta)) {
// achromatic case, hue is undefined
color.ct.ahsv.hue = USHRT_MAX;
color.ct.ahsv.saturation = 0;
@@ -1441,7 +1441,7 @@ QColor QColor::toCmyk() const
// cmy -> cmyk
const qreal k = qMin(c, qMin(m, y));
- if (!qFuzzyCompare(k,1)) {
+ if (!qFuzzyIsNull(k - 1)) {
c = (c - k) / (1.0 - k);
m = (m - k) / (1.0 - k);
y = (y - k) / (1.0 - k);
diff --git a/src/gui/painting/qmatrix.h b/src/gui/painting/qmatrix.h
index 1b6bd6d..1e5fbb4 100644
--- a/src/gui/painting/qmatrix.h
+++ b/src/gui/painting/qmatrix.h
@@ -99,7 +99,7 @@ public:
QMatrix &shear(qreal sh, qreal sv);
QMatrix &rotate(qreal a);
- bool isInvertible() const { return !qFuzzyCompare(_m11*_m22 - _m12*_m21 + 1, 1); }
+ bool isInvertible() const { return !qFuzzyIsNull(_m11*_m22 - _m12*_m21); }
qreal det() const { return _m11*_m22 - _m12*_m21; }
QMatrix inverted(bool *invertible = 0) const;
@@ -161,8 +161,8 @@ Q_GUI_EXPORT QPainterPath operator *(const QPainterPath &p, const QMatrix &m);
inline bool QMatrix::isIdentity() const
{
- return qIsFuzzyNull(_m11 - 1) && qIsFuzzyNull(_m22 - 1) && qIsFuzzyNull(_m12)
- && qIsFuzzyNull(_m21) && qIsFuzzyNull(_dx) && qIsFuzzyNull(_dy);
+ return qFuzzyIsNull(_m11 - 1) && qFuzzyIsNull(_m22 - 1) && qFuzzyIsNull(_m12)
+ && qFuzzyIsNull(_m21) && qFuzzyIsNull(_dx) && qFuzzyIsNull(_dy);
}
/*****************************************************************************
diff --git a/src/gui/painting/qpaintengine_d3d.cpp b/src/gui/painting/qpaintengine_d3d.cpp
index bb81623..9a7638b 100644
--- a/src/gui/painting/qpaintengine_d3d.cpp
+++ b/src/gui/painting/qpaintengine_d3d.cpp
@@ -2506,8 +2506,8 @@ void QD3DDrawHelper::addTrap(const Trapezoid &trap)
qreal _rightA = (qreal)_w/_h;
qreal _rightB = topRightX - _rightA * topRightY;
- qreal invLeftA = qFuzzyCompare(_leftA + 1, 1) ? 0.0 : 1.0 / _leftA;
- qreal invRightA = qFuzzyCompare(_rightA + 1, 1) ? 0.0 : 1.0 / _rightA;
+ qreal invLeftA = qFuzzyIsNull(_leftA) ? 0.0 : 1.0 / _leftA;
+ qreal invRightA = qFuzzyIsNull(_rightA) ? 0.0 : 1.0 / _rightA;
vertex v1 = { {1.f, top - 1.f, 0.5f}, 0.f,
top, bottom, invLeftA, -invRightA,
@@ -2970,7 +2970,7 @@ qreal calculateAngle(qreal dx, qreal dy)
{
qreal angle;
- if (qFuzzyCompare(dx + 1, 1)) {
+ if (qFuzzyIsNull(dx)) {
angle = (dy < 0) ? -M_PI/2 : M_PI/2;
} else {
angle = atanf(dy/dx);
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index addd63d..92160f9 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -618,22 +618,22 @@ void QRasterPaintEngine::updateMatrix(const QTransform &matrix)
d->isPlain45DegreeRotation = false;
if (txop >= QTransform::TxRotate) {
d->isPlain45DegreeRotation =
- (qFuzzyCompare(matrix.m11() + 1, qreal(1))
- && qFuzzyCompare(matrix.m12(), qreal(1))
- && qFuzzyCompare(matrix.m21(), qreal(-1))
- && qFuzzyCompare(matrix.m22() + 1, qreal(1))
+ (qFuzzyIsNull(matrix.m11())
+ && qFuzzyIsNull(matrix.m12() - qreal(1))
+ && qFuzzyIsNull(matrix.m21() + qreal(1))
+ && qFuzzyIsNull(matrix.m22())
)
||
- (qFuzzyCompare(matrix.m11(), qreal(-1))
- && qFuzzyCompare(matrix.m12() + 1, qreal(1))
- && qFuzzyCompare(matrix.m21() + 1, qreal(1))
- && qFuzzyCompare(matrix.m22(), qreal(-1))
+ (qFuzzyIsNull(matrix.m11() + qreal(1))
+ && qFuzzyIsNull(matrix.m12())
+ && qFuzzyIsNull(matrix.m21())
+ && qFuzzyIsNull(matrix.m22() + qreal(1))
)
||
- (qFuzzyCompare(matrix.m11() + 1, qreal(1))
- && qFuzzyCompare(matrix.m12(), qreal(-1))
- && qFuzzyCompare(matrix.m21(), qreal(1))
- && qFuzzyCompare(matrix.m22() + 1, qreal(1))
+ (qFuzzyIsNull(matrix.m11())
+ && qFuzzyIsNull(matrix.m12() + qreal(1))
+ && qFuzzyIsNull(matrix.m21() - qreal(1))
+ && qFuzzyIsNull(matrix.m22())
)
;
}
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 2beb8c2..133520e 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -6055,22 +6055,22 @@ void QPainter::drawTextItem(const QPointF &p, const QTextItem &_ti)
const QTransform &m = d->state->matrix;
if (d->state->matrix.type() < QTransform::TxShear) {
bool isPlain90DegreeRotation =
- (qFuzzyCompare(m.m11() + 1, qreal(1))
- && qFuzzyCompare(m.m12(), qreal(1))
- && qFuzzyCompare(m.m21(), qreal(-1))
- && qFuzzyCompare(m.m22() + 1, qreal(1))
+ (qFuzzyIsNull(m.m11())
+ && qFuzzyIsNull(m.m12() - qreal(1))
+ && qFuzzyIsNull(m.m21() + qreal(1))
+ && qFuzzyIsNull(m.m22())
)
||
- (qFuzzyCompare(m.m11(), qreal(-1))
- && qFuzzyCompare(m.m12() + 1, qreal(1))
- && qFuzzyCompare(m.m21() + 1, qreal(1))
- && qFuzzyCompare(m.m22(), qreal(-1))
+ (qFuzzyIsNull(m.m11() + qreal(1))
+ && qFuzzyIsNull(m.m12())
+ && qFuzzyIsNull(m.m21())
+ && qFuzzyIsNull(m.m22() + qreal(1))
)
||
- (qFuzzyCompare(m.m11() + 1, qreal(1))
- && qFuzzyCompare(m.m12(), qreal(-1))
- && qFuzzyCompare(m.m21(), qreal(1))
- && qFuzzyCompare(m.m22() + 1, qreal(1))
+ (qFuzzyIsNull(m.m11())
+ && qFuzzyIsNull(m.m12() + qreal(1))
+ && qFuzzyIsNull(m.m21() - qreal(1))
+ && qFuzzyIsNull(m.m22())
)
;
aa = !isPlain90DegreeRotation;
diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp
index 6ae908c..d471aaa 100644
--- a/src/gui/painting/qpainterpath.cpp
+++ b/src/gui/painting/qpainterpath.cpp
@@ -1299,10 +1299,10 @@ static QRectF qt_painterpath_bezier_extrema(const QBezier &b)
qreal bx = QT_BEZIER_B(b, x);
qreal cx = QT_BEZIER_C(b, x);
// specialcase quadratic curves to avoid div by zero
- if (qFuzzyCompare(ax + 1, 1)) {
+ if (qFuzzyIsNull(ax)) {
// linear curves are covered by initialization.
- if (!qFuzzyCompare(bx + 1, 1)) {
+ if (!qFuzzyIsNull(bx)) {
qreal t = -cx / bx;
QT_BEZIER_CHECK_T(b, t);
}
@@ -1329,10 +1329,10 @@ static QRectF qt_painterpath_bezier_extrema(const QBezier &b)
qreal cy = QT_BEZIER_C(b, y);
// specialcase quadratic curves to avoid div by zero
- if (qFuzzyCompare(ay + 1, 1)) {
+ if (qFuzzyIsNull(ay)) {
// linear curves are covered by initialization.
- if (!qFuzzyCompare(by + 1, 1)) {
+ if (!qFuzzyIsNull(by)) {
qreal t = -cy / by;
QT_BEZIER_CHECK_T(b, t);
}
diff --git a/src/gui/painting/qpathclipper.cpp b/src/gui/painting/qpathclipper.cpp
index 297cdd3..9ef3eb7 100644
--- a/src/gui/painting/qpathclipper.cpp
+++ b/src/gui/painting/qpathclipper.cpp
@@ -138,11 +138,11 @@ bool QIntersectionFinder::linesIntersect(const QLineF &a, const QLineF &b) const
const qreal par = pDelta.x() * qDelta.y() - pDelta.y() * qDelta.x();
- if (qFuzzyCompare(par + 1, 1)) {
+ if (qFuzzyIsNull(par)) {
const QPointF normal(-pDelta.y(), pDelta.x());
// coinciding?
- if (qFuzzyCompare(dot(normal, q1 - p1) + 1, 1)) {
+ if (qFuzzyIsNull(dot(normal, q1 - p1))) {
const qreal dp = dot(pDelta, pDelta);
const qreal tq1 = dot(pDelta, q1 - p1);
@@ -202,13 +202,13 @@ void QIntersectionFinder::intersectBeziers(const QBezier &one, const QBezier &tw
qreal alpha_q = t.at(i).second;
QPointF pt;
- if (qFuzzyCompare(alpha_p + 1, 1)) {
+ if (qFuzzyIsNull(alpha_p)) {
pt = one.pt1();
- } else if (qFuzzyCompare(alpha_p, 1)) {
+ } else if (qFuzzyIsNull(alpha_p - 1)) {
pt = one.pt4();
- } else if (qFuzzyCompare(alpha_q + 1, 1)) {
+ } else if (qFuzzyIsNull(alpha_q)) {
pt = two.pt1();
- } else if (qFuzzyCompare(alpha_q, 1)) {
+ } else if (qFuzzyIsNull(alpha_q - 1)) {
pt = two.pt4();
} else {
pt = one.pointAt(alpha_p);
@@ -250,11 +250,11 @@ void QIntersectionFinder::intersectLines(const QLineF &a, const QLineF &b, QData
const qreal par = pDelta.x() * qDelta.y() - pDelta.y() * qDelta.x();
- if (qFuzzyCompare(par + 1, 1)) {
+ if (qFuzzyIsNull(par)) {
const QPointF normal(-pDelta.y(), pDelta.x());
// coinciding?
- if (qFuzzyCompare(dot(normal, q1 - p1) + 1, 1)) {
+ if (qFuzzyIsNull(dot(normal, q1 - p1))) {
const qreal invDp = 1 / dot(pDelta, pDelta);
const qreal tq1 = dot(pDelta, q1 - p1) * invDp;
@@ -315,11 +315,11 @@ void QIntersectionFinder::intersectLines(const QLineF &a, const QLineF &b, QData
if (tp<0 || tp>1 || tq<0 || tq>1)
return;
- const bool p_zero = qFuzzyCompare(tp + 1, 1);
- const bool p_one = qFuzzyCompare(tp, 1);
+ const bool p_zero = qFuzzyIsNull(tp);
+ const bool p_one = qFuzzyIsNull(tp - 1);
- const bool q_zero = qFuzzyCompare(tq + 1, 1);
- const bool q_one = qFuzzyCompare(tq, 1);
+ const bool q_zero = qFuzzyIsNull(tq);
+ const bool q_one = qFuzzyIsNull(tq - 1);
if ((q_zero || q_one) && (p_zero || p_one))
return;
@@ -922,7 +922,7 @@ qreal QWingedEdge::delta(int vertex, int a, int b) const
qreal result = b_angle - a_angle;
- if (qFuzzyCompare(result + 1, 1) || qFuzzyCompare(result, 128))
+ if (qFuzzyIsNull(result) || qFuzzyCompare(result, 128))
return 0;
if (result < 0)
@@ -951,7 +951,7 @@ static inline QPointF tangentAt(const QWingedEdge &list, int vi, int ei)
if (ep->bezier) {
normal = ep->bezier->derivedAt(t);
- if (qFuzzyCompare(normal.x() + 1, 1) && qFuzzyCompare(normal.y() + 1, 1))
+ if (qFuzzyIsNull(normal.x()) && qFuzzyIsNull(normal.y()))
normal = ep->bezier->secondDerivedAt(t);
} else {
const QPointF a = *list.vertex(ep->first);
@@ -1080,7 +1080,7 @@ QWingedEdge::TraversalStatus QWingedEdge::findInsertStatus(int vi, int ei) const
qDebug() << "Delta to edge" << status.edge << d2 << ", angles: " << op->angle << op->invAngle;
#endif
- if (!(qFuzzyCompare(d2 + 1, 1) && isLeftOf(*this, vi, status.edge, ei))
+ if (!(qFuzzyIsNull(d2) && isLeftOf(*this, vi, status.edge, ei))
&& (d2 < d || (qFuzzyCompare(d2, d) && isLeftOf(*this, vi, status.edge, position)))) {
position = status.edge;
d = d2;
@@ -1232,10 +1232,10 @@ int QWingedEdge::addEdge(int fi, int si, const QBezier *bezier, qreal t0, qreal
QPointF aTangent = bezier->derivedAt(t0);
QPointF bTangent = -bezier->derivedAt(t1);
- if (qFuzzyCompare(aTangent.x() + 1, 1) && qFuzzyCompare(aTangent.y() + 1, 1))
+ if (qFuzzyIsNull(aTangent.x()) && qFuzzyIsNull(aTangent.y()))
aTangent = bezier->secondDerivedAt(t0);
- if (qFuzzyCompare(bTangent.x() + 1, 1) && qFuzzyCompare(bTangent.y() + 1, 1))
+ if (qFuzzyIsNull(bTangent.x()) && qFuzzyIsNull(bTangent.y()))
bTangent = bezier->secondDerivedAt(t1);
ep->angle = computeAngle(aTangent);
@@ -1400,7 +1400,7 @@ static void addLineTo(QPainterPath &path, const QPointF &point)
const QPointF p(-d1.y(), d1.x());
- if (qFuzzyCompare(dot(p, d2) + 1, 1)) {
+ if (qFuzzyIsNull(dot(p, d2))) {
path.setElementPositionAt(elementCount - 1, point.x(), point.y());
return;
}
diff --git a/src/gui/painting/qstroker.cpp b/src/gui/painting/qstroker.cpp
index b894c62..5fffc72 100644
--- a/src/gui/painting/qstroker.cpp
+++ b/src/gui/painting/qstroker.cpp
@@ -763,7 +763,7 @@ template <class Iterator> bool qt_stroke_side(Iterator *it,
qreal qt_t_for_arc_angle(qreal angle)
{
- if (qFuzzyCompare(angle + 1, qreal(1)))
+ if (qFuzzyIsNull(angle))
return 0;
if (qFuzzyCompare(angle, qreal(90)))
@@ -904,13 +904,13 @@ QPointF qt_curves_for_arc(const QRectF &rect, qreal startAngle, qreal sweepLengt
}
// avoid empty start segment
- if (qFuzzyCompare(startT, qreal(1))) {
+ if (qFuzzyIsNull(startT - qreal(1))) {
startT = 0;
startSegment += delta;
}
// avoid empty end segment
- if (qFuzzyCompare(endT + 1, qreal(1))) {
+ if (qFuzzyIsNull(endT)) {
endT = 1;
endSegment -= delta;
}
@@ -918,8 +918,8 @@ QPointF qt_curves_for_arc(const QRectF &rect, qreal startAngle, qreal sweepLengt
startT = qt_t_for_arc_angle(startT * 90);
endT = qt_t_for_arc_angle(endT * 90);
- const bool splitAtStart = !qFuzzyCompare(startT + 1, qreal(1));
- const bool splitAtEnd = !qFuzzyCompare(endT, qreal(1));
+ const bool splitAtStart = !qFuzzyIsNull(startT);
+ const bool splitAtEnd = !qFuzzyIsNull(endT - qreal(1));
const int end = endSegment + delta;
@@ -1018,7 +1018,7 @@ void QDashStroker::processCurrentSubpath()
sumLength += dashes[i];
}
- if (qFuzzyCompare(sumLength + 1, qreal(1)))
+ if (qFuzzyIsNull(sumLength))
return;
Q_ASSERT(dashCount > 0);
diff --git a/src/gui/painting/qtessellator.cpp b/src/gui/painting/qtessellator.cpp
index e02f02d..ce5ab74 100644
--- a/src/gui/painting/qtessellator.cpp
+++ b/src/gui/painting/qtessellator.cpp
@@ -1436,7 +1436,7 @@ void QTessellator::tessellateRect(const QPointF &a_, const QPointF &b_, qreal wi
QPointF perp(pb.y() - pa.y(), pa.x() - pb.x());
qreal length = qSqrt(perp.x() * perp.x() + perp.y() * perp.y());
- if (qFuzzyCompare(length + 1, static_cast<qreal>(1)))
+ if (qFuzzyIsNull(length))
return;
// need the half of the width
diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp
index 6c37ab6..dfcca63 100644
--- a/src/gui/painting/qtransform.cpp
+++ b/src/gui/painting/qtransform.cpp
@@ -353,8 +353,8 @@ QTransform QTransform::inverted(bool *invertible) const
invert.affine._dy = -affine._dy;
break;
case TxScale:
- inv = !qIsFuzzyNull(affine._m11);
- inv &= !qIsFuzzyNull(affine._m22);
+ inv = !qFuzzyIsNull(affine._m11);
+ inv &= !qFuzzyIsNull(affine._m22);
if (inv) {
invert.affine._m11 = 1. / affine._m11;
invert.affine._m22 = 1. / affine._m22;
@@ -369,7 +369,7 @@ QTransform QTransform::inverted(bool *invertible) const
default:
// general case
qreal det = determinant();
- inv = !qIsFuzzyNull(det);
+ inv = !qFuzzyIsNull(det);
if (inv)
invert = adjoint() / det;
break;
@@ -1958,27 +1958,27 @@ QTransform::TransformationType QTransform::type() const
switch (static_cast<TransformationType>(m_dirty)) {
case TxProject:
- if (!qIsFuzzyNull(m_13) || !qIsFuzzyNull(m_23) || !qIsFuzzyNull(m_33 - 1)) {
+ if (!qFuzzyIsNull(m_13) || !qFuzzyIsNull(m_23) || !qFuzzyIsNull(m_33 - 1)) {
m_type = TxProject;
break;
}
case TxShear:
case TxRotate:
- if (!qIsFuzzyNull(affine._m12) || !qIsFuzzyNull(affine._m21)) {
+ if (!qFuzzyIsNull(affine._m12) || !qFuzzyIsNull(affine._m21)) {
const qreal dot = affine._m11 * affine._m12 + affine._m21 * affine._m22;
- if (qIsFuzzyNull(dot))
+ if (qFuzzyIsNull(dot))
m_type = TxRotate;
else
m_type = TxShear;
break;
}
case TxScale:
- if (!qIsFuzzyNull(affine._m11 - 1) || !qIsFuzzyNull(affine._m22 - 1)) {
+ if (!qFuzzyIsNull(affine._m11 - 1) || !qFuzzyIsNull(affine._m22 - 1)) {
m_type = TxScale;
break;
}
case TxTranslate:
- if (!qIsFuzzyNull(affine._dx) || !qIsFuzzyNull(affine._dy)) {
+ if (!qFuzzyIsNull(affine._dx) || !qFuzzyIsNull(affine._dy)) {
m_type = TxTranslate;
break;
}
diff --git a/src/gui/painting/qtransform.h b/src/gui/painting/qtransform.h
index 2d6c889..aac7c31 100644
--- a/src/gui/painting/qtransform.h
+++ b/src/gui/painting/qtransform.h
@@ -204,7 +204,7 @@ inline bool QTransform::isIdentity() const
inline bool QTransform::isInvertible() const
{
- return !qIsFuzzyNull(determinant());
+ return !qFuzzyIsNull(determinant());
}
inline bool QTransform::isScaling() const
diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp
index 09a51fe..f30ece4 100644
--- a/src/gui/widgets/qcombobox.cpp
+++ b/src/gui/widgets/qcombobox.cpp
@@ -949,6 +949,7 @@ QComboBoxPrivateContainer* QComboBoxPrivate::viewContainer()
container->itemView()->setTextElideMode(Qt::ElideMiddle);
updateDelegate();
updateLayoutDirection();
+ updateViewContainerPaletteAndOpacity();
QObject::connect(container, SIGNAL(itemSelected(QModelIndex)),
q, SLOT(_q_itemSelected(QModelIndex)));
QObject::connect(container->itemView()->selectionModel(),
@@ -1051,6 +1052,27 @@ void QComboBoxPrivate::_q_rowsRemoved(const QModelIndex &parent, int /*start*/,
}
+void QComboBoxPrivate::updateViewContainerPaletteAndOpacity()
+{
+ if (!container)
+ return;
+ Q_Q(QComboBox);
+ QStyleOptionComboBox opt;
+ q->initStyleOption(&opt);
+#ifndef QT_NO_MENU
+ if (q->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, q)) {
+ QMenu menu;
+ menu.ensurePolished();
+ container->setPalette(menu.palette());
+ container->setWindowOpacity(menu.windowOpacity());
+ } else
+#endif
+ {
+ container->setPalette(q->palette());
+ container->setWindowOpacity(1.0);
+ }
+}
+
/*!
Initialize \a option with the values from this QComboBox. This method
is useful for subclasses when they need a QStyleOptionComboBox, but don't want
@@ -2572,20 +2594,7 @@ void QComboBox::changeEvent(QEvent *e)
hidePopup();
break;
case QEvent::PaletteChange: {
- QStyleOptionComboBox opt;
- initStyleOption(&opt);
-#ifndef QT_NO_MENU
- if (style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, this)) {
- QMenu menu;
- menu.ensurePolished();
- d->viewContainer()->setPalette(menu.palette());
- d->viewContainer()->setWindowOpacity(menu.windowOpacity());
- } else
-#endif
- {
- d->viewContainer()->setPalette(palette());
- d->viewContainer()->setWindowOpacity(1.0);
- }
+ d->updateViewContainerPaletteAndOpacity();
break;
}
case QEvent::FontChange:
diff --git a/src/gui/widgets/qcombobox_p.h b/src/gui/widgets/qcombobox_p.h
index c39a231..a0b76cf 100644
--- a/src/gui/widgets/qcombobox_p.h
+++ b/src/gui/widgets/qcombobox_p.h
@@ -370,6 +370,7 @@ public:
void updateDelegate();
void keyboardSearchString(const QString &text);
void modelChanged();
+ void updateViewContainerPaletteAndOpacity();
QAbstractItemModel *model;
QLineEdit *lineEdit;