diff options
Diffstat (limited to 'src/gui/painting/qrasterizer.cpp')
-rw-r--r-- | src/gui/painting/qrasterizer.cpp | 59 |
1 files changed, 31 insertions, 28 deletions
diff --git a/src/gui/painting/qrasterizer.cpp b/src/gui/painting/qrasterizer.cpp index bfd53b6d1..b602690f3 100644 --- a/src/gui/painting/qrasterizer.cpp +++ b/src/gui/painting/qrasterizer.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -9,8 +10,8 @@ ** 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. +** contained in the Technology Preview License Agreement accompanying +** this package. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -20,21 +21,20 @@ ** 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. +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** ** -** 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 http://qt.nokia.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -310,7 +310,7 @@ struct QBoolToType template <typename T> void qScanConvert(QScanConverter &d, T allVertical) { - qSort(d.m_lines.data(), d.m_lines.data() + d.m_lines.size(), topOrder); + qSort(d.m_lines.data(), d.m_lines.data() + d.m_lines.size(), QT_PREPEND_NAMESPACE(topOrder)); int line = 0; for (int y = d.m_lines.first().top; y <= d.m_bottom; ++y) { for (; line < d.m_lines.size() && d.m_lines.at(line).top == y; ++line) { @@ -319,7 +319,7 @@ void qScanConvert(QScanConverter &d, T allVertical) QScanConverter::Line *l = &d.m_lines.at(line); d.m_active.resize(d.m_active.size() + 1); int j; - for (j = d.m_active.size() - 2; j >= 0 && xOrder(l, d.m_active.at(j)); --j) + for (j = d.m_active.size() - 2; j >= 0 && QT_PREPEND_NAMESPACE(xOrder)(l, d.m_active.at(j)); --j) d.m_active.at(j+1) = d.m_active.at(j); d.m_active.at(j+1) = l; } else { @@ -334,7 +334,7 @@ void qScanConvert(QScanConverter &d, T allVertical) for (int i = 1; i < numActive; ++i) { QScanConverter::Line *l = d.m_active.at(i); int j; - for (j = i-1; j >= 0 && xOrder(l, d.m_active.at(j)); --j) + for (j = i-1; j >= 0 && QT_PREPEND_NAMESPACE(xOrder)(l, d.m_active.at(j)); --j) d.m_active.at(j+1) = d.m_active.at(j); d.m_active.at(j+1) = l; } @@ -436,8 +436,9 @@ void QScanConverter::end() inline void QScanConverter::allocate(int size) { if (m_alloc < size) { - m_alloc = qMax(size, 2 * m_alloc); - m_intersections = (Intersection *)realloc(m_intersections, m_alloc * sizeof(Intersection)); + int newAlloc = qMax(size, 2 * m_alloc); + m_intersections = q_check_ptr((Intersection *)realloc(m_intersections, newAlloc * sizeof(Intersection))); + m_alloc = newAlloc; } } @@ -691,14 +692,14 @@ static inline bool q16Dot16Compare(qreal p1, qreal p2) return FloatToQ16Dot16(p2 - p1) == 0; } -static inline qreal qRoundF(qreal v) +static inline qreal qFloorF(qreal v) { #ifdef QT_USE_MATH_H_FLOATS if (sizeof(qreal) == sizeof(float)) - return floorf(v + 0.5); + return floorf(v); else #endif - return floor(v + 0.5); + return floor(v); } void QRasterizer::rasterizeLine(const QPointF &a, const QPointF &b, qreal width, bool squareCap) @@ -706,10 +707,12 @@ void QRasterizer::rasterizeLine(const QPointF &a, const QPointF &b, qreal width, if (a == b || width == 0 || d->clipRect.isEmpty()) return; + Q_ASSERT(width > 0.0); + QPointF pa = a; QPointF pb = b; - QPointF offs = QPointF(qAbs(b.y() - a.y()), qAbs(b.x() - a.x())) * width * 0.5; + QPointF offs = QPointF(qAbs(b.y() - a.y()), qAbs(b.x() - a.x())) * width * 0.5; if (squareCap) offs += QPointF(offs.y(), offs.x()); const QRectF clip(d->clipRect.topLeft() - offs, d->clipRect.bottomRight() + QPoint(1, 1) + offs); @@ -758,10 +761,10 @@ void QRasterizer::rasterizeLine(const QPointF &a, const QPointF &b, qreal width, const qreal reciprocal = 1 / gridResolution; // snap to grid to prevent large slopes - pa.rx() = qRoundF(pa.rx() * gridResolution) * reciprocal; - pa.ry() = qRoundF(pa.ry() * gridResolution) * reciprocal; - pb.rx() = qRoundF(pb.rx() * gridResolution) * reciprocal; - pb.ry() = qRoundF(pb.ry() * gridResolution) * reciprocal; + pa.rx() = qFloorF(pa.rx() * gridResolution) * reciprocal; + pa.ry() = qFloorF(pa.ry() * gridResolution) * reciprocal; + pb.rx() = qFloorF(pb.rx() * gridResolution) * reciprocal; + pb.ry() = qFloorF(pb.ry() * gridResolution) * reciprocal; // old delta const QPointF d0 = a - b; |