Changeset 846 for trunk/src/svg


Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/svg/qgraphicssvgitem.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    125125    \snippet doc/src/snippets/code/src_svg_qgraphicssvgitem.cpp 0
    126126
    127     Size of the item can be set via the setSize() method or via
    128     direct manipulation of the items transformation matrix.
     127    Size of the item can be set via the \l{QRectF::setSize()}
     128    {setSize()} method of the \l{QGraphicsSvgItem::boundingRect()}
     129    {bounding rectangle} or via direct manipulation of the items
     130    transformation matrix.
    129131
    130132    By default the SVG rendering is cached using QGraphicsItem::DeviceCoordinateCache
  • trunk/src/svg/qgraphicssvgitem.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/svg/qsvgfont.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/svg/qsvgfont_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/svg/qsvggenerator.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    311311        *d_func()->stream << QLatin1String("fill=\"none\" ");
    312312        *d_func()->stream << QLatin1String("stroke=\"black\" ");
    313         *d_func()->stream << QLatin1String("vector-effect=\"non-scaling-stroke\" ");
    314313        *d_func()->stream << QLatin1String("stroke-width=\"1\" ");
    315314        *d_func()->stream << QLatin1String("fill-rule=\"evenodd\" ");
     
    381380        }
    382381
    383         if (spen.widthF() == 0) {
    384             width = QLatin1String("1");
    385             stream() << "vector-effect=\"non-scaling-stroke\" ";
    386         }
     382        if (spen.widthF() == 0)
     383            stream() <<"stroke-width=\"1\" ";
    387384        else
    388             width = QString::number(spen.widthF());
    389         stream() <<"stroke-width=\""<<width<<"\" ";
     385            stream() <<"stroke-width=\"" << spen.widthF() << "\" ";
    390386
    391387        switch (spen.capStyle()) {
     
    984980    Q_D(QSvgPaintEngine);
    985981
    986     *d->stream << "<path "
    987                   "fill-rule=";
    988     if (p.fillRule() == Qt::OddEvenFill)
    989         *d->stream << "\"evenodd\" ";
    990     else
    991         *d->stream << "\"nonzero\" ";
    992 
    993     *d->stream << "d=\"";
     982    *d->stream << "<path vector-effect=\""
     983               << (state->pen().isCosmetic() ? "non-scaling-stroke" : "none")
     984               << "\" fill-rule=\""
     985               << (p.fillRule() == Qt::OddEvenFill ? "evenodd" : "nonzero")
     986               << "\" d=\"";
    994987
    995988    for (int i=0; i<p.elementCount(); ++i) {
     
    10391032
    10401033    if (mode == PolylineMode) {
    1041         stream() << "<polyline fill=\"none\" points=\"";
     1034        stream() << "<polyline fill=\"none\" vector-effect=\""
     1035                 << (state->pen().isCosmetic() ? "non-scaling-stroke" : "none")
     1036                 << "\" points=\"";
    10421037        for (int i = 0; i < pointCount; ++i) {
    10431038            const QPointF &pt = points[i];
  • trunk/src/svg/qsvggenerator.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/svg/qsvggraphics.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    7979}
    8080
    81 static inline QRectF boundsOnStroke(const QPainterPath &path, qreal width)
     81static inline QRectF boundsOnStroke(QPainter *p, const QPainterPath &path, qreal width)
    8282{
    8383    QPainterPathStroker stroker;
    8484    stroker.setWidth(width);
    8585    QPainterPath stroke = stroker.createStroke(path);
    86     return stroke.boundingRect();
    87 }
    88 
    89 QSvgCircle::QSvgCircle(QSvgNode *parent, const QRectF &rect)
     86    return p->transform().map(stroke).boundingRect();
     87}
     88
     89QSvgEllipse::QSvgEllipse(QSvgNode *parent, const QRectF &rect)
    9090    : QSvgNode(parent), m_bounds(rect)
    9191{
     
    9393
    9494
    95 QRectF QSvgCircle::bounds() const
    96 {
    97     qreal sw = strokeWidth();
    98     if (qFuzzyIsNull(sw))
    99         return m_bounds;
    100     else {
    101         QPainterPath path;
    102         path.addRect(m_bounds);
    103         return boundsOnStroke(path, sw);
    104     }
    105 }
    106 
    107 void QSvgCircle::draw(QPainter *p, QSvgExtraStates &states)
     95QRectF QSvgEllipse::bounds(QPainter *p, QSvgExtraStates &) const
     96{
     97    QPainterPath path;
     98    path.addEllipse(m_bounds);
     99    qreal sw = strokeWidth(p);
     100    return qFuzzyIsNull(sw) ? p->transform().map(path).boundingRect() : boundsOnStroke(p, path, sw);
     101}
     102
     103void QSvgEllipse::draw(QPainter *p, QSvgExtraStates &states)
    108104{
    109105    applyStyle(p, states);
     
    113109
    114110QSvgArc::QSvgArc(QSvgNode *parent, const QPainterPath &path)
    115     : QSvgNode(parent), cubic(path)
    116 {
    117     m_cachedBounds = path.boundingRect();
     111    : QSvgNode(parent), m_path(path)
     112{
    118113}
    119114
     
    124119        qreal oldOpacity = p->opacity();
    125120        p->setOpacity(oldOpacity * states.strokeOpacity);
    126         p->drawPath(cubic);
     121        p->drawPath(m_path);
    127122        p->setOpacity(oldOpacity);
    128123    }
    129     revertStyle(p, states);
    130 }
    131 
    132 QSvgEllipse::QSvgEllipse(QSvgNode *parent, const QRectF &rect)
    133     : QSvgNode(parent), m_bounds(rect)
    134 {
    135 }
    136 
    137 QRectF QSvgEllipse::bounds() const
    138 {
    139     qreal sw = strokeWidth();
    140     if (qFuzzyIsNull(sw))
    141         return m_bounds;
    142     else {
    143         QPainterPath path;
    144         path.addEllipse(m_bounds);
    145         return boundsOnStroke(path, sw);
    146     }
    147 }
    148 
    149 void QSvgEllipse::draw(QPainter *p, QSvgExtraStates &states)
    150 {
    151     applyStyle(p, states);
    152     QT_SVG_DRAW_SHAPE(p->drawEllipse(m_bounds));
    153124    revertStyle(p, states);
    154125}
     
    174145
    175146QSvgLine::QSvgLine(QSvgNode *parent, const QLineF &line)
    176     : QSvgNode(parent), m_bounds(line)
     147    : QSvgNode(parent), m_line(line)
    177148{
    178149}
     
    185156        qreal oldOpacity = p->opacity();
    186157        p->setOpacity(oldOpacity * states.strokeOpacity);
    187         p->drawLine(m_bounds);
     158        p->drawLine(m_line);
    188159        p->setOpacity(oldOpacity);
    189160    }
     
    204175}
    205176
    206 QRectF QSvgPath::bounds() const
    207 {
    208     qreal sw = strokeWidth();
    209     if (qFuzzyIsNull(sw)) {
    210         if (m_cachedBounds.isNull())
    211             //m_cachedBounds = m_path.controlPointRect();
    212             m_cachedBounds = m_path.boundingRect();
    213 
    214         return m_cachedBounds;
    215     }
    216     else {
    217         return boundsOnStroke(m_path, sw);
    218     }
     177QRectF QSvgPath::bounds(QPainter *p, QSvgExtraStates &) const
     178{
     179    qreal sw = strokeWidth(p);
     180    return qFuzzyIsNull(sw) ? p->transform().map(m_path).boundingRect()
     181        : boundsOnStroke(p, m_path, sw);
    219182}
    220183
     
    224187}
    225188
    226 QRectF QSvgPolygon::bounds() const
    227 {
    228     qreal sw = strokeWidth();
    229     if (qFuzzyIsNull(sw))
    230         return m_poly.boundingRect();
    231     else {
     189QRectF QSvgPolygon::bounds(QPainter *p, QSvgExtraStates &) const
     190{
     191    qreal sw = strokeWidth(p);
     192    if (qFuzzyIsNull(sw)) {
     193        return p->transform().map(m_poly).boundingRect();
     194    } else {
    232195        QPainterPath path;
    233196        path.addPolygon(m_poly);
    234         return boundsOnStroke(path, sw);
     197        return boundsOnStroke(p, path, sw);
    235198    }
    236199}
     
    275238}
    276239
    277 QRectF QSvgRect::bounds() const
    278 {
    279     qreal sw = strokeWidth();
    280     if (qFuzzyIsNull(sw))
    281         return m_rect;
    282     else {
     240QRectF QSvgRect::bounds(QPainter *p, QSvgExtraStates &) const
     241{
     242    qreal sw = strokeWidth(p);
     243    if (qFuzzyIsNull(sw)) {
     244        return p->transform().mapRect(m_rect);
     245    } else {
    283246        QPainterPath path;
    284247        path.addRect(m_rect);
    285         return boundsOnStroke(path, sw);
     248        return boundsOnStroke(p, path, sw);
    286249    }
    287250}
     
    323286}
    324287
    325 //QRectF QSvgText::bounds() const {}
     288//QRectF QSvgText::bounds(QPainter *p, QSvgExtraStates &) const {}
    326289
    327290void QSvgText::draw(QPainter *p, QSvgExtraStates &states)
     
    594557}
    595558
    596 QRectF QSvgUse::bounds() const
    597 {
    598     if (m_link && m_bounds.isEmpty())  {
    599         m_bounds = m_link->bounds();
    600         m_bounds = QRectF(m_bounds.x()+m_start.x(),
    601                           m_bounds.y()+m_start.y(),
    602                           m_bounds.width(),
    603                           m_bounds.height());
    604 
    605         return m_bounds;
    606     }
    607     return m_bounds;
    608 }
    609 
    610 QRectF QSvgUse::transformedBounds(const QTransform &transform) const
     559QRectF QSvgUse::bounds(QPainter *p, QSvgExtraStates &states) const
    611560{
    612561    QRectF bounds;
    613     QTransform t = transform;
    614 
    615     if (m_link)  {
    616         QSvgTransformStyle *transStyle = m_style.transform;
    617         if (transStyle) {
    618             t = transStyle->qtransform() * t;
    619         }
    620         t.translate(m_start.x(), m_start.y());
    621 
    622         bounds = m_link->transformedBounds(t);
    623 
    624         return bounds;
     562    if (m_link) {
     563        p->translate(m_start);
     564        bounds = m_link->transformedBounds(p, states);
     565        p->translate(-m_start);
    625566    }
    626567    return bounds;
    627568}
    628569
    629 QRectF QSvgPolyline::bounds() const
    630 {
    631     qreal sw = strokeWidth();
    632     if (qFuzzyIsNull(sw))
    633         return m_poly.boundingRect();
    634     else {
     570QRectF QSvgPolyline::bounds(QPainter *p, QSvgExtraStates &) const
     571{
     572    qreal sw = strokeWidth(p);
     573    if (qFuzzyIsNull(sw)) {
     574        return p->transform().map(m_poly).boundingRect();
     575    } else {
    635576        QPainterPath path;
    636577        path.addPolygon(m_poly);
    637         return boundsOnStroke(path, sw);
    638     }
    639 }
    640 
    641 QRectF QSvgArc::bounds() const
    642 {
    643     qreal sw = strokeWidth();
    644     if (qFuzzyIsNull(sw))
    645         return m_cachedBounds;
    646     else {
    647         return boundsOnStroke(cubic, sw);
    648     }
    649 }
    650 
    651 QRectF QSvgImage::bounds() const
    652 {
    653     return m_bounds;
    654 }
    655 
    656 QRectF QSvgLine::bounds() const
    657 {
    658     qreal sw = strokeWidth();
     578        return boundsOnStroke(p, path, sw);
     579    }
     580}
     581
     582QRectF QSvgArc::bounds(QPainter *p, QSvgExtraStates &) const
     583{
     584    qreal sw = strokeWidth(p);
     585    return qFuzzyIsNull(sw) ? p->transform().map(m_path).boundingRect()
     586        : boundsOnStroke(p, m_path, sw);
     587}
     588
     589QRectF QSvgImage::bounds(QPainter *p, QSvgExtraStates &) const
     590{
     591    return p->transform().mapRect(m_bounds);
     592}
     593
     594QRectF QSvgLine::bounds(QPainter *p, QSvgExtraStates &) const
     595{
     596    qreal sw = strokeWidth(p);
    659597    if (qFuzzyIsNull(sw)) {
    660         qreal minX = qMin(m_bounds.x1(), m_bounds.x2());
    661         qreal minY = qMin(m_bounds.y1(), m_bounds.y2());
    662         qreal maxX = qMax(m_bounds.x1(), m_bounds.x2());
    663         qreal maxY = qMax(m_bounds.y1(), m_bounds.y2());
    664         return QRectF(minX, minY, maxX-minX, maxY-minY);
     598        QPointF p1 = p->transform().map(m_line.p1());
     599        QPointF p2 = p->transform().map(m_line.p2());
     600        qreal minX = qMin(p1.x(), p2.x());
     601        qreal minY = qMin(p1.y(), p2.y());
     602        qreal maxX = qMax(p1.x(), p2.x());
     603        qreal maxY = qMax(p1.y(), p2.y());
     604        return QRectF(minX, minY, maxX - minX, maxY - minY);
    665605    } else {
    666606        QPainterPath path;
    667         path.moveTo(m_bounds.x1(), m_bounds.y1());
    668         path.lineTo(m_bounds.x2(), m_bounds.y2());
    669         return boundsOnStroke(path, sw);
     607        path.moveTo(m_line.p1());
     608        path.lineTo(m_line.p2());
     609        return boundsOnStroke(p, path, sw);
    670610    }
    671611}
  • trunk/src/svg/qsvggraphics_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    8181    virtual void draw(QPainter *p, QSvgExtraStates &states);
    8282    virtual Type type() const;
    83     virtual QRectF bounds() const;
    84 private:
    85     QPainterPath cubic;
    86     QRectF m_cachedBounds;
    87 };
    88 
    89 class QSvgCircle : public QSvgNode
    90 {
    91 public:
    92     QSvgCircle(QSvgNode *parent, const QRectF &rect);
    93     virtual void draw(QPainter *p, QSvgExtraStates &states);
    94     virtual Type type() const;
    95     virtual QRectF bounds() const;
     83    virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
     84private:
     85    QPainterPath m_path;
     86};
     87
     88class QSvgEllipse : public QSvgNode
     89{
     90public:
     91    QSvgEllipse(QSvgNode *parent, const QRectF &rect);
     92    virtual void draw(QPainter *p, QSvgExtraStates &states);
     93    virtual Type type() const;
     94    virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
    9695private:
    9796    QRectF m_bounds;
    9897};
    9998
    100 class QSvgEllipse : public QSvgNode
    101 {
    102 public:
    103     QSvgEllipse(QSvgNode *parent, const QRectF &rect);
    104     virtual void draw(QPainter *p, QSvgExtraStates &states);
    105     virtual Type type() const;
    106     virtual QRectF bounds() const;
    107 private:
    108     QRectF m_bounds;
     99class QSvgCircle : public QSvgEllipse
     100{
     101public:
     102    QSvgCircle(QSvgNode *parent, const QRectF &rect) : QSvgEllipse(parent, rect) { }
     103    virtual Type type() const;
    109104};
    110105
     
    116111    virtual void draw(QPainter *p, QSvgExtraStates &states);
    117112    virtual Type type() const;
    118     virtual QRectF bounds() const;
     113    virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
    119114private:
    120115    QImage m_image;
     
    128123    virtual void draw(QPainter *p, QSvgExtraStates &states);
    129124    virtual Type type() const;
    130     virtual QRectF bounds() const;
    131 private:
    132     QLineF m_bounds;
     125    virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
     126private:
     127    QLineF m_line;
    133128};
    134129
     
    139134    virtual void draw(QPainter *p, QSvgExtraStates &states);
    140135    virtual Type type() const;
    141     virtual QRectF bounds() const;
     136    virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
    142137
    143138    QPainterPath *qpath() {
     
    146141private:
    147142    QPainterPath m_path;
    148     mutable QRectF m_cachedBounds;
    149143};
    150144
     
    155149    virtual void draw(QPainter *p, QSvgExtraStates &states);
    156150    virtual Type type() const;
    157     virtual QRectF bounds() const;
     151    virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
    158152private:
    159153    QPolygonF m_poly;
     
    166160    virtual void draw(QPainter *p, QSvgExtraStates &states);
    167161    virtual Type type() const;
    168     virtual QRectF bounds() const;
     162    virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
    169163private:
    170164    QPolygonF m_poly;
     
    177171    virtual Type type() const;
    178172    virtual void draw(QPainter *p, QSvgExtraStates &states);
    179     virtual QRectF bounds() const;
     173    virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
    180174private:
    181175    QRectF m_rect;
     
    206200    void setWhitespaceMode(WhitespaceMode mode) {m_mode = mode;}
    207201
    208     //virtual QRectF bounds() const;
     202    //virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
    209203private:
    210204    static QSvgTspan * const LINEBREAK;
     
    249243    virtual void draw(QPainter *p, QSvgExtraStates &states);
    250244    virtual Type type() const;
    251     virtual QRectF bounds() const;
    252     virtual QRectF transformedBounds(const QTransform &transform) const;
     245    virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
    253246
    254247private:
    255248    QSvgNode *m_link;
    256249    QPointF   m_start;
    257     mutable QRectF    m_bounds;
    258250};
    259251
  • trunk/src/svg/qsvghandler.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    7575#define QT_INHERIT QLatin1String(qt_inherit_text)
    7676
    77 Q_DECL_IMPORT double qstrtod(const char *s00, char const **se, bool *ok);
     77Q_CORE_EXPORT double qstrtod(const char *s00, char const **se, bool *ok);
    7878
    7979// ======== duplicated from qcolor_p
     
    12831283
    12841284    if (!attributes.fontSize.isEmpty() && attributes.fontSize != QT_INHERIT) {
     1285        // TODO: Support relative sizes 'larger' and 'smaller'.
    12851286        QSvgHandler::LengthType dummy; // should always be pixel size
    1286         fontStyle->setSize(parseLength(attributes.fontSize.toString(), dummy, handler));
     1287        qreal size = 0;
     1288        static const qreal sizeTable[] = { qreal(6.9), qreal(8.3), qreal(10.0), qreal(12.0), qreal(14.4), qreal(17.3), qreal(20.7) };
     1289        enum AbsFontSize { XXSmall, XSmall, Small, Medium, Large, XLarge, XXLarge };
     1290        switch (attributes.fontSize.at(0).unicode()) {
     1291        case 'x':
     1292            if (attributes.fontSize == QLatin1String("xx-small"))
     1293                size = sizeTable[XXSmall];
     1294            else if (attributes.fontSize == QLatin1String("x-small"))
     1295                size = sizeTable[XSmall];
     1296            else if (attributes.fontSize == QLatin1String("x-large"))
     1297                size = sizeTable[XLarge];
     1298            else if (attributes.fontSize == QLatin1String("xx-large"))
     1299                size = sizeTable[XXLarge];
     1300            break;
     1301        case 's':
     1302            if (attributes.fontSize == QLatin1String("small"))
     1303                size = sizeTable[Small];
     1304            break;
     1305        case 'm':
     1306            if (attributes.fontSize == QLatin1String("medium"))
     1307                size = sizeTable[Medium];
     1308            break;
     1309        case 'l':
     1310            if (attributes.fontSize == QLatin1String("large"))
     1311                size = sizeTable[Large];
     1312            break;
     1313        default:
     1314            size = parseLength(attributes.fontSize.toString(), dummy, handler);
     1315            break;
     1316        }
     1317        fontStyle->setSize(size);
    12871318    }
    12881319
     
    29632994        nry = bounds.height()/2;
    29642995
    2965     if (nrx && !nry)
     2996    if (!rx.isEmpty() && ry.isEmpty())
    29662997        nry = nrx;
    2967     else if (nry && !nrx)
     2998    else if (!ry.isEmpty() && rx.isEmpty())
    29682999        nrx = nry;
    29693000
     
    35263557            // this point is to do what everyone else seems to do and
    35273558            // ignore the reported namespaceUri completely.
    3528             startElement(xml->name().toString(), xml->attributes());
     3559            if (!startElement(xml->name().toString(), xml->attributes())) {
     3560                delete m_doc;
     3561                m_doc = 0;
     3562                return;
     3563            }
    35293564            break;
    35303565        case QXmlStreamReader::EndElement:
     
    35703605        m_whitespaceMode.push(QSvgText::Default);
    35713606    }
     3607
     3608    if (!m_doc && localName != QLatin1String("svg"))
     3609        return false;
    35723610
    35733611    if (FactoryMethod method = findGroupFactory(localName)) {
     
    37453783        m_selector->styleSheets.append(sheet);
    37463784        return true;
    3747     } else if (m_skipNodes.isEmpty() || m_skipNodes.top() == Unknown)
     3785    } else if (m_skipNodes.isEmpty() || m_skipNodes.top() == Unknown || m_nodes.isEmpty())
    37483786        return true;
    37493787
  • trunk/src/svg/qsvghandler_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/svg/qsvgnode.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4646
    4747#include "qdebug.h"
     48#include "qstack.h"
    4849
    4950QT_BEGIN_NAMESPACE
     
    115116}
    116117
    117 void QSvgNode::applyStyle(QPainter *p, QSvgExtraStates &states)
    118 {
    119     m_style.apply(p, bounds(), this, states);
    120 }
    121 
    122 void QSvgNode::revertStyle(QPainter *p, QSvgExtraStates &states)
     118void QSvgNode::applyStyle(QPainter *p, QSvgExtraStates &states) const
     119{
     120    m_style.apply(p, this, states);
     121}
     122
     123void QSvgNode::revertStyle(QPainter *p, QSvgExtraStates &states) const
    123124{
    124125    m_style.revert(p, states);
     
    196197}
    197198
    198 QRectF QSvgNode::bounds() const
     199QRectF QSvgNode::bounds(QPainter *, QSvgExtraStates &) const
    199200{
    200201    return QRectF(0, 0, 0, 0);
     202}
     203
     204QRectF QSvgNode::transformedBounds() const
     205{
     206    if (!m_cachedBounds.isEmpty())
     207        return m_cachedBounds;
     208
     209    QImage dummy(1, 1, QImage::Format_RGB32);
     210    QPainter p(&dummy);
     211    QSvgExtraStates states;
     212
     213    QPen pen(Qt::NoBrush, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
     214    pen.setMiterLimit(4);
     215    p.setPen(pen);
     216
     217    QStack<QSvgNode*> parentApplyStack;
     218    QSvgNode *parent = m_parent;
     219    while (parent) {
     220        parentApplyStack.push(parent);
     221        parent = parent->parent();
     222    }
     223
     224    for (int i = parentApplyStack.size() - 1; i >= 0; --i)
     225        parentApplyStack[i]->applyStyle(&p, states);
     226   
     227    p.setWorldTransform(QTransform());
     228
     229    m_cachedBounds = transformedBounds(&p, states);
     230    return m_cachedBounds;
    201231}
    202232
     
    275305}
    276306
    277 QRectF QSvgNode::transformedBounds(const QTransform &transform) const
    278 {
    279     QTransform t = transform;
    280 
    281     QSvgTransformStyle *transStyle = m_style.transform;
    282     if (transStyle) {
    283         t = transStyle->qtransform() * t;
    284     }
    285 
    286     QRectF rect = bounds();
    287 
    288     rect = t.mapRect(rect);
    289 
     307QRectF QSvgNode::transformedBounds(QPainter *p, QSvgExtraStates &states) const
     308{
     309    applyStyle(p, states);
     310    QRectF rect = bounds(p, states);
     311    revertStyle(p, states);
    290312    return rect;
    291313}
     
    311333}
    312334
    313 qreal QSvgNode::strokeWidth() const
    314 {
    315     QSvgStrokeStyle *stroke = static_cast<QSvgStrokeStyle*>(
    316         styleProperty(QSvgStyleProperty::STROKE));
    317     if (!stroke)
     335qreal QSvgNode::strokeWidth(QPainter *p)
     336{
     337    QPen pen = p->pen();
     338    if (pen.style() == Qt::NoPen || pen.brush().style() == Qt::NoBrush || pen.isCosmetic())
    318339        return 0;
    319     if (stroke->stroke().brush().style() == Qt::NoBrush)
    320         return 0;
    321     return stroke->width();
     340    return pen.widthF();
    322341}
    323342
  • trunk/src/svg/qsvgnode_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    119119
    120120    void appendStyleProperty(QSvgStyleProperty *prop, const QString &id);
    121     void applyStyle(QPainter *p, QSvgExtraStates &states);
    122     void revertStyle(QPainter *p, QSvgExtraStates &states);
     121    void applyStyle(QPainter *p, QSvgExtraStates &states) const;
     122    void revertStyle(QPainter *p, QSvgExtraStates &states) const;
    123123    QSvgStyleProperty *styleProperty(QSvgStyleProperty::Type type) const;
    124124    QSvgFillStyleProperty *styleProperty(const QString &id) const;
     
    127127
    128128    virtual Type type() const =0;
    129     virtual QRectF bounds() const;
    130     virtual QRectF transformedBounds(const QTransform &transform) const;
     129    virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
     130    virtual QRectF transformedBounds(QPainter *p, QSvgExtraStates &states) const;
     131    QRectF transformedBounds() const;
    131132
    132133    void setRequiredFeatures(const QStringList &lst);
     
    157158    void setXmlClass(const QString &str);
    158159protected:
    159     QSvgStyle  m_style;
    160 
    161     qreal strokeWidth() const;
     160    mutable QSvgStyle m_style;
     161
     162    static qreal strokeWidth(QPainter *p);
    162163private:
    163164    QSvgNode   *m_parent;
     
    175176
    176177    DisplayMode m_displayMode;
     178    mutable QRectF m_cachedBounds;
    177179
    178180    friend class QSvgTinyDocument;
  • trunk/src/svg/qsvgrenderer.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/svg/qsvgrenderer.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/svg/qsvgstructure.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    358358}
    359359
    360 QRectF QSvgStructureNode::bounds() const
    361 {
    362     if (m_bounds.isEmpty()) {
    363         foreach(QSvgNode *node, m_renderers) {
    364             m_bounds |= node->transformedBounds(QTransform());
    365         }
    366     }
    367 
    368     return m_bounds;
     360QRectF QSvgStructureNode::bounds(QPainter *p, QSvgExtraStates &states) const
     361{
     362    QRectF bounds;
     363    foreach(QSvgNode *node, m_renderers)
     364        bounds |= node->transformedBounds(p, states);
     365    return bounds;
    369366}
    370367
  • trunk/src/svg/qsvgstructure_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    7575    QSvgNode *scopeNode(const QString &id) const;
    7676    void addChild(QSvgNode *child, const QString &id);
    77     virtual QRectF bounds() const;
     77    virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
    7878    QSvgNode *previousSiblingNode(QSvgNode *n) const;
    7979    QList<QSvgNode*> renderers() const { return m_renderers; }
     
    8282    QHash<QString, QSvgNode*> m_scope;
    8383    QList<QSvgStructureNode*> m_linkedScopes;
    84     mutable QRectF m_bounds;
    8584};
    8685
  • trunk/src/svg/qsvgstyle.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    7474}
    7575
    76 void QSvgFillStyleProperty::apply(QPainter *, const QRectF &, QSvgNode *, QSvgExtraStates &)
     76void QSvgFillStyleProperty::apply(QPainter *, const QSvgNode *, QSvgExtraStates &)
    7777{
    7878    Q_ASSERT(!"This should not be called!");
     
    9090
    9191}
    92 void QSvgQualityStyle::apply(QPainter *, const QRectF &, QSvgNode *, QSvgExtraStates &)
     92void QSvgQualityStyle::apply(QPainter *, const QSvgNode *, QSvgExtraStates &)
    9393{
    9494
     
    137137}
    138138
    139 void QSvgFillStyle::apply(QPainter *p, const QRectF &, QSvgNode *, QSvgExtraStates &states)
     139void QSvgFillStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &states)
    140140{
    141141    m_oldFill = p->brush();
     
    170170}
    171171
    172 void QSvgViewportFillStyle::apply(QPainter *p, const QRectF &, QSvgNode *, QSvgExtraStates &)
     172void QSvgViewportFillStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &)
    173173{
    174174    m_oldFill = p->brush();
     
    225225}
    226226
    227 void QSvgFontStyle::apply(QPainter *p, const QRectF &, QSvgNode *, QSvgExtraStates &states)
     227void QSvgFontStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &states)
    228228{
    229229    m_oldQFont = p->font();
     
    242242
    243243    if (m_sizeSet)
    244         font.setPointSize(m_qfont.pointSizeF());
     244        font.setPointSizeF(m_qfont.pointSizeF());
    245245
    246246    if (m_styleSet)
     
    293293}
    294294
    295 void QSvgStrokeStyle::apply(QPainter *p, const QRectF &, QSvgNode *, QSvgExtraStates &states)
     295void QSvgStrokeStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &states)
    296296{
    297297    m_oldStroke = p->pen();
     
    444444}
    445445
    446 void QSvgTransformStyle::apply(QPainter *p, const QRectF &, QSvgNode *, QSvgExtraStates &)
     446void QSvgTransformStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &)
    447447{
    448448    m_oldWorldTransform = p->worldTransform();
     
    502502}
    503503
    504 void QSvgCompOpStyle::apply(QPainter *p, const QRectF &, QSvgNode *, QSvgExtraStates &)
     504void QSvgCompOpStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &)
    505505{
    506506    m_oldMode = p->compositionMode();
     
    522522}
    523523
    524 void QSvgStyle::apply(QPainter *p, const QRectF &rect, QSvgNode *node, QSvgExtraStates &states)
     524void QSvgStyle::apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states)
    525525{
    526526    if (quality) {
    527         quality->apply(p, rect, node, states);
     527        quality->apply(p, node, states);
    528528    }
    529529
    530530    if (fill) {
    531         fill->apply(p, rect, node, states);
     531        fill->apply(p, node, states);
    532532    }
    533533
    534534    if (viewportFill) {
    535         viewportFill->apply(p, rect, node, states);
     535        viewportFill->apply(p, node, states);
    536536    }
    537537
    538538    if (font) {
    539         font->apply(p, rect, node, states);
     539        font->apply(p, node, states);
    540540    }
    541541
    542542    if (stroke) {
    543         stroke->apply(p, rect, node, states);
     543        stroke->apply(p, node, states);
    544544    }
    545545
    546546    if (transform) {
    547         transform->apply(p, rect, node, states);
     547        transform->apply(p, node, states);
    548548    }
    549549
    550550    if (animateColor) {
    551         animateColor->apply(p, rect, node, states);
     551        animateColor->apply(p, node, states);
    552552    }
    553553
     
    573573        for (; itr != animateTransforms.constEnd(); ++itr) {
    574574            if ((*itr)->animActive(totalTimeElapsed))
    575                 (*itr)->apply(p, rect, node, states);
     575                (*itr)->apply(p, node, states);
    576576        }
    577577    }
    578578
    579579    if (opacity) {
    580         opacity->apply(p, rect, node, states);
     580        opacity->apply(p, node, states);
    581581    }
    582582
    583583    if (compop) {
    584         compop->apply(p, rect, node, states);
     584        compop->apply(p, node, states);
    585585    }
    586586}
     
    656656}
    657657
    658 void QSvgAnimateTransform::apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &)
     658void QSvgAnimateTransform::apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &)
    659659{
    660660    m_oldWorldTransform = p->worldTransform();
     
    670670}
    671671
    672 void QSvgAnimateTransform::resolveMatrix(QSvgNode *node)
     672void QSvgAnimateTransform::resolveMatrix(const QSvgNode *node)
    673673{
    674674    static const qreal deg2rad = qreal(0.017453292519943295769);
     
    835835}
    836836
    837 void QSvgAnimateColor::apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &)
     837void QSvgAnimateColor::apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &)
    838838{
    839839    qreal totalTimeElapsed = node->document()->currentElapsed();
     
    913913}
    914914
    915 void QSvgOpacityStyle::apply(QPainter *p, const QRectF &, QSvgNode *, QSvgExtraStates &)
     915void QSvgOpacityStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &)
    916916{
    917917    m_oldOpacity = p->opacity();
  • trunk/src/svg/qsvgstyle_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    173173public:
    174174    virtual ~QSvgStyleProperty();
    175     virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states)  =0;
     175    virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states) = 0;
    176176    virtual void revert(QPainter *p, QSvgExtraStates &states) =0;
    177177    virtual Type type() const=0;
     
    182182public:
    183183    virtual QBrush brush(QPainter *p, QSvgExtraStates &states) = 0;
    184     virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states);
     184    virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
    185185    virtual void revert(QPainter *p, QSvgExtraStates &states);
    186186};
     
    190190public:
    191191    QSvgQualityStyle(int color);
    192     virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states);
     192    virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
    193193    virtual void revert(QPainter *p, QSvgExtraStates &states);
    194194    virtual Type type() const;
     
    222222public:
    223223    QSvgOpacityStyle(qreal opacity);
    224     virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states);
     224    virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
    225225    virtual void revert(QPainter *p, QSvgExtraStates &states);
    226226    virtual Type type() const;
     
    234234public:
    235235    QSvgFillStyle();
    236     virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states);
     236    virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
    237237    virtual void revert(QPainter *p, QSvgExtraStates &states);
    238238    virtual Type type() const;
     
    307307public:
    308308    QSvgViewportFillStyle(const QBrush &brush);
    309     virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states);
     309    virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
    310310    virtual void revert(QPainter *p, QSvgExtraStates &states);
    311311    virtual Type type() const;
     
    331331    QSvgFontStyle(QSvgFont *font, QSvgTinyDocument *doc);
    332332    QSvgFontStyle();
    333     virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states);
     333    virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
    334334    virtual void revert(QPainter *p, QSvgExtraStates &states);
    335335    virtual Type type() const;
     
    339339        // Store the _pixel_ size in the font. Since QFont::setPixelSize() only takes an int, call
    340340        // QFont::SetPointSize() instead. Set proper font size just before rendering.
    341         m_qfont.setPointSize(size);
     341        m_qfont.setPointSizeF(size);
    342342        m_sizeSet = 1;
    343343    }
     
    411411public:
    412412    QSvgStrokeStyle();
    413     virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states);
     413    virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
    414414    virtual void revert(QPainter *p, QSvgExtraStates &states);
    415415    virtual Type type() const;
     
    618618public:
    619619    QSvgTransformStyle(const QTransform &transform);
    620     virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states);
     620    virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
    621621    virtual void revert(QPainter *p, QSvgExtraStates &states);
    622622    virtual Type type() const;
     
    655655    void setFreeze(bool freeze);
    656656    void setRepeatCount(qreal repeatCount);
    657     virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states);
     657    virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
    658658    virtual void revert(QPainter *p, QSvgExtraStates &states);
    659659    virtual Type type() const;
     
    689689
    690690protected:
    691     void resolveMatrix(QSvgNode *node);
     691    void resolveMatrix(const QSvgNode *node);
    692692private:
    693693    qreal m_from, m_to, m_by;
     
    713713    void setFreeze(bool freeze);
    714714    void setRepeatCount(qreal repeatCount);
    715     virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states);
     715    virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
    716716    virtual void revert(QPainter *p, QSvgExtraStates &states);
    717717    virtual Type type() const;
     
    733733public:
    734734    QSvgCompOpStyle(QPainter::CompositionMode mode);
    735     virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states);
     735    virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
    736736    virtual void revert(QPainter *p, QSvgExtraStates &states);
    737737    virtual Type type() const;
     
    767767    ~QSvgStyle();
    768768
    769     void apply(QPainter *p, const QRectF &rect, QSvgNode *node, QSvgExtraStates &states);
     769    void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
    770770    void revert(QPainter *p, QSvgExtraStates &states);
    771771    QSvgRefCounter<QSvgQualityStyle>      quality;
  • trunk/src/svg/qsvgtinydocument.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    278278    p->save();
    279279
    280     const QRectF elementBounds = node->transformedBounds(QTransform());
     280    const QRectF elementBounds = node->transformedBounds();
    281281
    282282    mapSourceToTarget(p, bounds, elementBounds);
     
    300300    for (int i = parentApplyStack.size() - 1; i >= 0; --i)
    301301        parentApplyStack[i]->applyStyle(p, m_states);
    302    
     302
    303303    // Reset the world transform so that our parents don't affect
    304304    // the position
     
    433433    if (!node)
    434434        node = this;
    435 
    436     return node->transformedBounds(QTransform());
     435    return node->transformedBounds();
    437436}
    438437
  • trunk/src/svg/qsvgtinydocument_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    174174inline QRectF QSvgTinyDocument::viewBox() const
    175175{
    176     if (m_viewBox.isNull()) {
    177         m_viewBox = transformedBounds(QTransform());
    178     }
     176    if (m_viewBox.isNull())
     177        m_viewBox = transformedBounds();
    179178
    180179    return m_viewBox;
  • trunk/src/svg/qsvgwidget.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/svg/qsvgwidget.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/svg/svg.pro

    r561 r846  
    4343symbian:TARGET.UID3=0x2001B2E2
    4444
    45 #zlib support
    46 contains(QT_CONFIG, zlib) {
    47    INCLUDEPATH += ../3rdparty/zlib
    48 } else:!contains(QT_CONFIG, no-zlib) {
    49    unix:LIBS_PRIVATE += -lz
    50 }
     45include(../3rdparty/zlib_dependency.pri)
Note: See TracChangeset for help on using the changeset viewer.