Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/painting/qstroker.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    453453
    454454    if (join == FlatJoin) {
     455        QLineF prevLine(qt_fixed_to_real(m_back2X), qt_fixed_to_real(m_back2Y),
     456                        qt_fixed_to_real(m_back1X), qt_fixed_to_real(m_back1Y));
     457        QPointF isect;
     458        QLineF::IntersectType type = prevLine.intersect(nextLine, &isect);
     459        QLineF shortCut(prevLine.p2(), nextLine.p1());
     460        qreal angle = shortCut.angleTo(prevLine);
     461        if (type == QLineF::BoundedIntersection || (angle > 90 && !qFuzzyCompare(angle, (qreal)90))) {
     462            emitLineTo(focal_x, focal_y);
     463            emitLineTo(qt_real_to_fixed(nextLine.x1()), qt_real_to_fixed(nextLine.y1()));
     464            return;
     465        }
    455466        emitLineTo(qt_real_to_fixed(nextLine.x1()),
    456467                   qt_real_to_fixed(nextLine.y1()));
     
    469480            QLineF shortCut(prevLine.p2(), nextLine.p1());
    470481            qreal angle = shortCut.angleTo(prevLine);
    471 
    472482            if (type == QLineF::BoundedIntersection || (angle > 90 && !qFuzzyCompare(angle, (qreal)90))) {
     483                emitLineTo(focal_x, focal_y);
    473484                emitLineTo(qt_real_to_fixed(nextLine.x1()), qt_real_to_fixed(nextLine.y1()));
    474485                return;
     
    510521
    511522            QLineF shortCut(prevLine.p2(), nextLine.p1());
    512             qreal angle = prevLine.angle(shortCut);
     523            qreal angle = shortCut.angleTo(prevLine);
    513524            if (type == QLineF::BoundedIntersection || (angle > 90 && !qFuzzyCompare(angle, (qreal)90))) {
     525                emitLineTo(focal_x, focal_y);
    514526                emitLineTo(qt_real_to_fixed(nextLine.x1()), qt_real_to_fixed(nextLine.y1()));
    515527                return;
     
    582594                        qt_real_to_fixed(l1.y1()));
    583595        } else if (join == SvgMiterJoin) {
     596            QLineF shortCut(prevLine.p2(), nextLine.p1());
     597            qreal angle = shortCut.angleTo(prevLine);
     598            if (type == QLineF::BoundedIntersection || (angle > 90 && !qFuzzyCompare(angle, (qreal)90))) {
     599                emitLineTo(focal_x, focal_y);
     600                emitLineTo(qt_real_to_fixed(nextLine.x1()), qt_real_to_fixed(nextLine.y1()));
     601                return;
     602            }
    584603            QLineF miterLine(QPointF(qt_fixed_to_real(focal_x),
    585604                                     qt_fixed_to_real(focal_y)), isect);
     
    764783qreal qt_t_for_arc_angle(qreal angle)
    765784{
    766     if (qFuzzyCompare(angle + 1, qreal(1)))
     785    if (qFuzzyIsNull(angle))
    767786        return 0;
    768787
     
    892911    }
    893912
    894     int startSegment = int(floor(startAngle / 90));
    895     int endSegment = int(floor((startAngle + sweepLength) / 90));
     913    int startSegment = int(qFloor(startAngle / 90));
     914    int endSegment = int(qFloor((startAngle + sweepLength) / 90));
    896915
    897916    qreal startT = (startAngle - startSegment * 90) / 90;
     
    905924
    906925    // avoid empty start segment
    907     if (qFuzzyCompare(startT, qreal(1))) {
     926    if (qFuzzyIsNull(startT - qreal(1))) {
    908927        startT = 0;
    909928        startSegment += delta;
     
    911930
    912931    // avoid empty end segment
    913     if (qFuzzyCompare(endT + 1, qreal(1))) {
     932    if (qFuzzyIsNull(endT)) {
    914933        endT = 1;
    915934        endSegment -= delta;
     
    919938    endT = qt_t_for_arc_angle(endT * 90);
    920939
    921     const bool splitAtStart = !qFuzzyCompare(startT + 1, qreal(1));
    922     const bool splitAtEnd = !qFuzzyCompare(endT, qreal(1));
     940    const bool splitAtStart = !qFuzzyIsNull(startT);
     941    const bool splitAtEnd = !qFuzzyIsNull(endT - qreal(1));
    923942
    924943    const int end = endSegment + delta;
     
    970989
    971990
     991static inline void qdashstroker_moveTo(qfixed x, qfixed y, void *data) {
     992    ((QStroker *) data)->moveTo(x, y);
     993}
     994
     995static inline void qdashstroker_lineTo(qfixed x, qfixed y, void *data) {
     996    ((QStroker *) data)->lineTo(x, y);
     997}
     998
     999static inline void qdashstroker_cubicTo(qfixed, qfixed, qfixed, qfixed, qfixed, qfixed, void *) {
     1000    Q_ASSERT(0);
     1001//     ((QStroker *) data)->cubicTo(c1x, c1y, c2x, c2y, ex, ey);
     1002}
     1003
     1004
    9721005/*******************************************************************************
    9731006 * QDashStroker members
    9741007 */
    9751008QDashStroker::QDashStroker(QStroker *stroker)
    976     : m_stroker(stroker), m_dashOffset(0)
    977 {
    978 
     1009    : m_stroker(stroker), m_dashOffset(0), m_stroke_width(1), m_miter_limit(1)
     1010{
     1011    if (m_stroker) {
     1012        setMoveToHook(qdashstroker_moveTo);
     1013        setLineToHook(qdashstroker_lineTo);
     1014        setCubicToHook(qdashstroker_cubicTo);
     1015    }
    9791016}
    9801017
     
    10131050    qfixed dashes[32];
    10141051
     1052    if (m_stroker) {
     1053        m_customData = m_stroker;
     1054        m_stroke_width = m_stroker->strokeWidth();
     1055        m_miter_limit = m_stroker->miterLimit();
     1056    }
     1057
     1058    qreal longestLength = 0;
    10151059    qreal sumLength = 0;
    10161060    for (int i=0; i<dashCount; ++i) {
    1017         dashes[i] = qMax(m_dashPattern.at(i), qreal(0)) * m_stroker->strokeWidth();
     1061        dashes[i] = qMax(m_dashPattern.at(i), qreal(0)) * m_stroke_width;
    10181062        sumLength += dashes[i];
    1019     }
    1020 
    1021     if (qFuzzyCompare(sumLength + 1, qreal(1)))
     1063        if (dashes[i] > longestLength)
     1064            longestLength = dashes[i];
     1065    }
     1066
     1067    if (qFuzzyIsNull(sumLength))
    10221068        return;
    10231069
     
    10291075    qreal pos = 0; // The position on the curve, 0 <= pos <= path.length
    10301076    qreal elen = 0; // element length
    1031     qreal doffset = m_dashOffset * m_stroker->strokeWidth();
     1077    qreal doffset = m_dashOffset * m_stroke_width;
    10321078
    10331079    // make sure doffset is in range [0..sumLength)
     
    10541100
    10551101    // Pad to avoid clipping the borders of thick pens.
    1056     qfixed padding = qMax(m_stroker->strokeWidth(), m_stroker->miterLimit());
     1102    qfixed padding = qt_real_to_fixed(qMax(m_stroke_width, m_miter_limit) * longestLength);
    10571103    qfixed2d clip_tl = { qt_real_to_fixed(m_clip_rect.left()) - padding,
    10581104                         qt_real_to_fixed(m_clip_rect.top()) - padding };
     
    11061152                // new subpath.
    11071153                if (!has_offset || !hasMoveTo) {
    1108                     m_stroker->moveTo(move_to_pos.x, move_to_pos.y);
     1154                    emitMoveTo(move_to_pos.x, move_to_pos.y);
    11091155                    hasMoveTo = true;
    11101156                }
     
    11181164                     && line_to_pos.y > clip_tl.y && line_to_pos.y < clip_br.y))
    11191165                {
    1120                     m_stroker->lineTo(line_to_pos.x, line_to_pos.y);
     1166                    emitLineTo(line_to_pos.x, line_to_pos.y);
    11211167                }
    11221168            } else {
     
    11321178        prev = e;
    11331179    }
     1180
    11341181}
    11351182
Note: See TracChangeset for help on using the changeset viewer.