Changeset 846 for trunk/src/svg
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/svg/qgraphicssvgitem.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 125 125 \snippet doc/src/snippets/code/src_svg_qgraphicssvgitem.cpp 0 126 126 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. 129 131 130 132 By default the SVG rendering is cached using QGraphicsItem::DeviceCoordinateCache -
trunk/src/svg/qgraphicssvgitem.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/svg/qsvgfont.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/svg/qsvgfont_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/svg/qsvggenerator.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 311 311 *d_func()->stream << QLatin1String("fill=\"none\" "); 312 312 *d_func()->stream << QLatin1String("stroke=\"black\" "); 313 *d_func()->stream << QLatin1String("vector-effect=\"non-scaling-stroke\" ");314 313 *d_func()->stream << QLatin1String("stroke-width=\"1\" "); 315 314 *d_func()->stream << QLatin1String("fill-rule=\"evenodd\" "); … … 381 380 } 382 381 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\" "; 387 384 else 388 width = QString::number(spen.widthF()); 389 stream() <<"stroke-width=\""<<width<<"\" "; 385 stream() <<"stroke-width=\"" << spen.widthF() << "\" "; 390 386 391 387 switch (spen.capStyle()) { … … 984 980 Q_D(QSvgPaintEngine); 985 981 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=\""; 994 987 995 988 for (int i=0; i<p.elementCount(); ++i) { … … 1039 1032 1040 1033 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=\""; 1042 1037 for (int i = 0; i < pointCount; ++i) { 1043 1038 const QPointF &pt = points[i]; -
trunk/src/svg/qsvggenerator.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/svg/qsvggraphics.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 79 79 } 80 80 81 static inline QRectF boundsOnStroke( const QPainterPath &path, qreal width)81 static inline QRectF boundsOnStroke(QPainter *p, const QPainterPath &path, qreal width) 82 82 { 83 83 QPainterPathStroker stroker; 84 84 stroker.setWidth(width); 85 85 QPainterPath stroke = stroker.createStroke(path); 86 return stroke.boundingRect();87 } 88 89 QSvg Circle::QSvgCircle(QSvgNode *parent, const QRectF &rect)86 return p->transform().map(stroke).boundingRect(); 87 } 88 89 QSvgEllipse::QSvgEllipse(QSvgNode *parent, const QRectF &rect) 90 90 : QSvgNode(parent), m_bounds(rect) 91 91 { … … 93 93 94 94 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) 95 QRectF 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 103 void QSvgEllipse::draw(QPainter *p, QSvgExtraStates &states) 108 104 { 109 105 applyStyle(p, states); … … 113 109 114 110 QSvgArc::QSvgArc(QSvgNode *parent, const QPainterPath &path) 115 : QSvgNode(parent), cubic(path) 116 { 117 m_cachedBounds = path.boundingRect(); 111 : QSvgNode(parent), m_path(path) 112 { 118 113 } 119 114 … … 124 119 qreal oldOpacity = p->opacity(); 125 120 p->setOpacity(oldOpacity * states.strokeOpacity); 126 p->drawPath( cubic);121 p->drawPath(m_path); 127 122 p->setOpacity(oldOpacity); 128 123 } 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() const138 {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));153 124 revertStyle(p, states); 154 125 } … … 174 145 175 146 QSvgLine::QSvgLine(QSvgNode *parent, const QLineF &line) 176 : QSvgNode(parent), m_ bounds(line)147 : QSvgNode(parent), m_line(line) 177 148 { 178 149 } … … 185 156 qreal oldOpacity = p->opacity(); 186 157 p->setOpacity(oldOpacity * states.strokeOpacity); 187 p->drawLine(m_ bounds);158 p->drawLine(m_line); 188 159 p->setOpacity(oldOpacity); 189 160 } … … 204 175 } 205 176 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 } 177 QRectF 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); 219 182 } 220 183 … … 224 187 } 225 188 226 QRectF QSvgPolygon::bounds( ) const227 { 228 qreal sw = strokeWidth( );229 if (qFuzzyIsNull(sw)) 230 return m_poly.boundingRect();231 else {189 QRectF 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 { 232 195 QPainterPath path; 233 196 path.addPolygon(m_poly); 234 return boundsOnStroke(p ath, sw);197 return boundsOnStroke(p, path, sw); 235 198 } 236 199 } … … 275 238 } 276 239 277 QRectF QSvgRect::bounds( ) const278 { 279 qreal sw = strokeWidth( );280 if (qFuzzyIsNull(sw)) 281 return m_rect;282 else {240 QRectF 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 { 283 246 QPainterPath path; 284 247 path.addRect(m_rect); 285 return boundsOnStroke(p ath, sw);248 return boundsOnStroke(p, path, sw); 286 249 } 287 250 } … … 323 286 } 324 287 325 //QRectF QSvgText::bounds( ) const {}288 //QRectF QSvgText::bounds(QPainter *p, QSvgExtraStates &) const {} 326 289 327 290 void QSvgText::draw(QPainter *p, QSvgExtraStates &states) … … 594 557 } 595 558 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 559 QRectF QSvgUse::bounds(QPainter *p, QSvgExtraStates &states) const 611 560 { 612 561 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); 625 566 } 626 567 return bounds; 627 568 } 628 569 629 QRectF QSvgPolyline::bounds( ) const630 { 631 qreal sw = strokeWidth( );632 if (qFuzzyIsNull(sw)) 633 return m_poly.boundingRect();634 else {570 QRectF 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 { 635 576 QPainterPath path; 636 577 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 582 QRectF 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 589 QRectF QSvgImage::bounds(QPainter *p, QSvgExtraStates &) const 590 { 591 return p->transform().mapRect(m_bounds); 592 } 593 594 QRectF QSvgLine::bounds(QPainter *p, QSvgExtraStates &) const 595 { 596 qreal sw = strokeWidth(p); 659 597 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); 665 605 } else { 666 606 QPainterPath path; 667 path.moveTo(m_ bounds.x1(), m_bounds.y1());668 path.lineTo(m_ bounds.x2(), m_bounds.y2());669 return boundsOnStroke(p ath, sw);607 path.moveTo(m_line.p1()); 608 path.lineTo(m_line.p2()); 609 return boundsOnStroke(p, path, sw); 670 610 } 671 611 } -
trunk/src/svg/qsvggraphics_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 81 81 virtual void draw(QPainter *p, QSvgExtraStates &states); 82 82 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; 84 private: 85 QPainterPath m_path; 86 }; 87 88 class QSvgEllipse : public QSvgNode 89 { 90 public: 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; 96 95 private: 97 96 QRectF m_bounds; 98 97 }; 99 98 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; 99 class QSvgCircle : public QSvgEllipse 100 { 101 public: 102 QSvgCircle(QSvgNode *parent, const QRectF &rect) : QSvgEllipse(parent, rect) { } 103 virtual Type type() const; 109 104 }; 110 105 … … 116 111 virtual void draw(QPainter *p, QSvgExtraStates &states); 117 112 virtual Type type() const; 118 virtual QRectF bounds( ) const;113 virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const; 119 114 private: 120 115 QImage m_image; … … 128 123 virtual void draw(QPainter *p, QSvgExtraStates &states); 129 124 virtual Type type() const; 130 virtual QRectF bounds( ) const;131 private: 132 QLineF m_ bounds;125 virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const; 126 private: 127 QLineF m_line; 133 128 }; 134 129 … … 139 134 virtual void draw(QPainter *p, QSvgExtraStates &states); 140 135 virtual Type type() const; 141 virtual QRectF bounds( ) const;136 virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const; 142 137 143 138 QPainterPath *qpath() { … … 146 141 private: 147 142 QPainterPath m_path; 148 mutable QRectF m_cachedBounds;149 143 }; 150 144 … … 155 149 virtual void draw(QPainter *p, QSvgExtraStates &states); 156 150 virtual Type type() const; 157 virtual QRectF bounds( ) const;151 virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const; 158 152 private: 159 153 QPolygonF m_poly; … … 166 160 virtual void draw(QPainter *p, QSvgExtraStates &states); 167 161 virtual Type type() const; 168 virtual QRectF bounds( ) const;162 virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const; 169 163 private: 170 164 QPolygonF m_poly; … … 177 171 virtual Type type() const; 178 172 virtual void draw(QPainter *p, QSvgExtraStates &states); 179 virtual QRectF bounds( ) const;173 virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const; 180 174 private: 181 175 QRectF m_rect; … … 206 200 void setWhitespaceMode(WhitespaceMode mode) {m_mode = mode;} 207 201 208 //virtual QRectF bounds( ) const;202 //virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const; 209 203 private: 210 204 static QSvgTspan * const LINEBREAK; … … 249 243 virtual void draw(QPainter *p, QSvgExtraStates &states); 250 244 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; 253 246 254 247 private: 255 248 QSvgNode *m_link; 256 249 QPointF m_start; 257 mutable QRectF m_bounds;258 250 }; 259 251 -
trunk/src/svg/qsvghandler.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 75 75 #define QT_INHERIT QLatin1String(qt_inherit_text) 76 76 77 Q_ DECL_IMPORT double qstrtod(const char *s00, char const **se, bool *ok);77 Q_CORE_EXPORT double qstrtod(const char *s00, char const **se, bool *ok); 78 78 79 79 // ======== duplicated from qcolor_p … … 1283 1283 1284 1284 if (!attributes.fontSize.isEmpty() && attributes.fontSize != QT_INHERIT) { 1285 // TODO: Support relative sizes 'larger' and 'smaller'. 1285 1286 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); 1287 1318 } 1288 1319 … … 2963 2994 nry = bounds.height()/2; 2964 2995 2965 if ( nrx && !nry)2996 if (!rx.isEmpty() && ry.isEmpty()) 2966 2997 nry = nrx; 2967 else if ( nry && !nrx)2998 else if (!ry.isEmpty() && rx.isEmpty()) 2968 2999 nrx = nry; 2969 3000 … … 3526 3557 // this point is to do what everyone else seems to do and 3527 3558 // 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 } 3529 3564 break; 3530 3565 case QXmlStreamReader::EndElement: … … 3570 3605 m_whitespaceMode.push(QSvgText::Default); 3571 3606 } 3607 3608 if (!m_doc && localName != QLatin1String("svg")) 3609 return false; 3572 3610 3573 3611 if (FactoryMethod method = findGroupFactory(localName)) { … … 3745 3783 m_selector->styleSheets.append(sheet); 3746 3784 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()) 3748 3786 return true; 3749 3787 -
trunk/src/svg/qsvghandler_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/svg/qsvgnode.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 46 46 47 47 #include "qdebug.h" 48 #include "qstack.h" 48 49 49 50 QT_BEGIN_NAMESPACE … … 115 116 } 116 117 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) 118 void QSvgNode::applyStyle(QPainter *p, QSvgExtraStates &states) const 119 { 120 m_style.apply(p, this, states); 121 } 122 123 void QSvgNode::revertStyle(QPainter *p, QSvgExtraStates &states) const 123 124 { 124 125 m_style.revert(p, states); … … 196 197 } 197 198 198 QRectF QSvgNode::bounds( ) const199 QRectF QSvgNode::bounds(QPainter *, QSvgExtraStates &) const 199 200 { 200 201 return QRectF(0, 0, 0, 0); 202 } 203 204 QRectF 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; 201 231 } 202 232 … … 275 305 } 276 306 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 307 QRectF QSvgNode::transformedBounds(QPainter *p, QSvgExtraStates &states) const 308 { 309 applyStyle(p, states); 310 QRectF rect = bounds(p, states); 311 revertStyle(p, states); 290 312 return rect; 291 313 } … … 311 333 } 312 334 313 qreal QSvgNode::strokeWidth() const 314 { 315 QSvgStrokeStyle *stroke = static_cast<QSvgStrokeStyle*>( 316 styleProperty(QSvgStyleProperty::STROKE)); 317 if (!stroke) 335 qreal QSvgNode::strokeWidth(QPainter *p) 336 { 337 QPen pen = p->pen(); 338 if (pen.style() == Qt::NoPen || pen.brush().style() == Qt::NoBrush || pen.isCosmetic()) 318 339 return 0; 319 if (stroke->stroke().brush().style() == Qt::NoBrush) 320 return 0; 321 return stroke->width(); 340 return pen.widthF(); 322 341 } 323 342 -
trunk/src/svg/qsvgnode_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 119 119 120 120 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; 123 123 QSvgStyleProperty *styleProperty(QSvgStyleProperty::Type type) const; 124 124 QSvgFillStyleProperty *styleProperty(const QString &id) const; … … 127 127 128 128 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; 131 132 132 133 void setRequiredFeatures(const QStringList &lst); … … 157 158 void setXmlClass(const QString &str); 158 159 protected: 159 QSvgStylem_style;160 161 qreal strokeWidth() const;160 mutable QSvgStyle m_style; 161 162 static qreal strokeWidth(QPainter *p); 162 163 private: 163 164 QSvgNode *m_parent; … … 175 176 176 177 DisplayMode m_displayMode; 178 mutable QRectF m_cachedBounds; 177 179 178 180 friend class QSvgTinyDocument; -
trunk/src/svg/qsvgrenderer.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/svg/qsvgrenderer.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/svg/qsvgstructure.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 358 358 } 359 359 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; 360 QRectF 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; 369 366 } 370 367 -
trunk/src/svg/qsvgstructure_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 75 75 QSvgNode *scopeNode(const QString &id) const; 76 76 void addChild(QSvgNode *child, const QString &id); 77 virtual QRectF bounds( ) const;77 virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const; 78 78 QSvgNode *previousSiblingNode(QSvgNode *n) const; 79 79 QList<QSvgNode*> renderers() const { return m_renderers; } … … 82 82 QHash<QString, QSvgNode*> m_scope; 83 83 QList<QSvgStructureNode*> m_linkedScopes; 84 mutable QRectF m_bounds;85 84 }; 86 85 -
trunk/src/svg/qsvgstyle.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 74 74 } 75 75 76 void QSvgFillStyleProperty::apply(QPainter *, const Q RectF &, QSvgNode *, QSvgExtraStates &)76 void QSvgFillStyleProperty::apply(QPainter *, const QSvgNode *, QSvgExtraStates &) 77 77 { 78 78 Q_ASSERT(!"This should not be called!"); … … 90 90 91 91 } 92 void QSvgQualityStyle::apply(QPainter *, const Q RectF &, QSvgNode *, QSvgExtraStates &)92 void QSvgQualityStyle::apply(QPainter *, const QSvgNode *, QSvgExtraStates &) 93 93 { 94 94 … … 137 137 } 138 138 139 void QSvgFillStyle::apply(QPainter *p, const Q RectF &, QSvgNode *, QSvgExtraStates &states)139 void QSvgFillStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &states) 140 140 { 141 141 m_oldFill = p->brush(); … … 170 170 } 171 171 172 void QSvgViewportFillStyle::apply(QPainter *p, const Q RectF &, QSvgNode *, QSvgExtraStates &)172 void QSvgViewportFillStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &) 173 173 { 174 174 m_oldFill = p->brush(); … … 225 225 } 226 226 227 void QSvgFontStyle::apply(QPainter *p, const Q RectF &, QSvgNode *, QSvgExtraStates &states)227 void QSvgFontStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &states) 228 228 { 229 229 m_oldQFont = p->font(); … … 242 242 243 243 if (m_sizeSet) 244 font.setPointSize (m_qfont.pointSizeF());244 font.setPointSizeF(m_qfont.pointSizeF()); 245 245 246 246 if (m_styleSet) … … 293 293 } 294 294 295 void QSvgStrokeStyle::apply(QPainter *p, const Q RectF &, QSvgNode *, QSvgExtraStates &states)295 void QSvgStrokeStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &states) 296 296 { 297 297 m_oldStroke = p->pen(); … … 444 444 } 445 445 446 void QSvgTransformStyle::apply(QPainter *p, const Q RectF &, QSvgNode *, QSvgExtraStates &)446 void QSvgTransformStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &) 447 447 { 448 448 m_oldWorldTransform = p->worldTransform(); … … 502 502 } 503 503 504 void QSvgCompOpStyle::apply(QPainter *p, const Q RectF &, QSvgNode *, QSvgExtraStates &)504 void QSvgCompOpStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &) 505 505 { 506 506 m_oldMode = p->compositionMode(); … … 522 522 } 523 523 524 void QSvgStyle::apply(QPainter *p, const Q RectF &rect, QSvgNode *node, QSvgExtraStates &states)524 void QSvgStyle::apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states) 525 525 { 526 526 if (quality) { 527 quality->apply(p, rect,node, states);527 quality->apply(p, node, states); 528 528 } 529 529 530 530 if (fill) { 531 fill->apply(p, rect,node, states);531 fill->apply(p, node, states); 532 532 } 533 533 534 534 if (viewportFill) { 535 viewportFill->apply(p, rect,node, states);535 viewportFill->apply(p, node, states); 536 536 } 537 537 538 538 if (font) { 539 font->apply(p, rect,node, states);539 font->apply(p, node, states); 540 540 } 541 541 542 542 if (stroke) { 543 stroke->apply(p, rect,node, states);543 stroke->apply(p, node, states); 544 544 } 545 545 546 546 if (transform) { 547 transform->apply(p, rect,node, states);547 transform->apply(p, node, states); 548 548 } 549 549 550 550 if (animateColor) { 551 animateColor->apply(p, rect,node, states);551 animateColor->apply(p, node, states); 552 552 } 553 553 … … 573 573 for (; itr != animateTransforms.constEnd(); ++itr) { 574 574 if ((*itr)->animActive(totalTimeElapsed)) 575 (*itr)->apply(p, rect,node, states);575 (*itr)->apply(p, node, states); 576 576 } 577 577 } 578 578 579 579 if (opacity) { 580 opacity->apply(p, rect,node, states);580 opacity->apply(p, node, states); 581 581 } 582 582 583 583 if (compop) { 584 compop->apply(p, rect,node, states);584 compop->apply(p, node, states); 585 585 } 586 586 } … … 656 656 } 657 657 658 void QSvgAnimateTransform::apply(QPainter *p, const Q RectF &, QSvgNode *node, QSvgExtraStates &)658 void QSvgAnimateTransform::apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &) 659 659 { 660 660 m_oldWorldTransform = p->worldTransform(); … … 670 670 } 671 671 672 void QSvgAnimateTransform::resolveMatrix( QSvgNode *node)672 void QSvgAnimateTransform::resolveMatrix(const QSvgNode *node) 673 673 { 674 674 static const qreal deg2rad = qreal(0.017453292519943295769); … … 835 835 } 836 836 837 void QSvgAnimateColor::apply(QPainter *p, const Q RectF &, QSvgNode *node, QSvgExtraStates &)837 void QSvgAnimateColor::apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &) 838 838 { 839 839 qreal totalTimeElapsed = node->document()->currentElapsed(); … … 913 913 } 914 914 915 void QSvgOpacityStyle::apply(QPainter *p, const Q RectF &, QSvgNode *, QSvgExtraStates &)915 void QSvgOpacityStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &) 916 916 { 917 917 m_oldOpacity = p->opacity(); -
trunk/src/svg/qsvgstyle_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 173 173 public: 174 174 virtual ~QSvgStyleProperty(); 175 virtual void apply(QPainter *p, const Q RectF &, QSvgNode *node, QSvgExtraStates &states) =0;175 virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states) = 0; 176 176 virtual void revert(QPainter *p, QSvgExtraStates &states) =0; 177 177 virtual Type type() const=0; … … 182 182 public: 183 183 virtual QBrush brush(QPainter *p, QSvgExtraStates &states) = 0; 184 virtual void apply(QPainter *p, const Q RectF &, QSvgNode *node, QSvgExtraStates &states);184 virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states); 185 185 virtual void revert(QPainter *p, QSvgExtraStates &states); 186 186 }; … … 190 190 public: 191 191 QSvgQualityStyle(int color); 192 virtual void apply(QPainter *p, const Q RectF &, QSvgNode *node, QSvgExtraStates &states);192 virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states); 193 193 virtual void revert(QPainter *p, QSvgExtraStates &states); 194 194 virtual Type type() const; … … 222 222 public: 223 223 QSvgOpacityStyle(qreal opacity); 224 virtual void apply(QPainter *p, const Q RectF &, QSvgNode *node, QSvgExtraStates &states);224 virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states); 225 225 virtual void revert(QPainter *p, QSvgExtraStates &states); 226 226 virtual Type type() const; … … 234 234 public: 235 235 QSvgFillStyle(); 236 virtual void apply(QPainter *p, const Q RectF &, QSvgNode *node, QSvgExtraStates &states);236 virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states); 237 237 virtual void revert(QPainter *p, QSvgExtraStates &states); 238 238 virtual Type type() const; … … 307 307 public: 308 308 QSvgViewportFillStyle(const QBrush &brush); 309 virtual void apply(QPainter *p, const Q RectF &, QSvgNode *node, QSvgExtraStates &states);309 virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states); 310 310 virtual void revert(QPainter *p, QSvgExtraStates &states); 311 311 virtual Type type() const; … … 331 331 QSvgFontStyle(QSvgFont *font, QSvgTinyDocument *doc); 332 332 QSvgFontStyle(); 333 virtual void apply(QPainter *p, const Q RectF &, QSvgNode *node, QSvgExtraStates &states);333 virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states); 334 334 virtual void revert(QPainter *p, QSvgExtraStates &states); 335 335 virtual Type type() const; … … 339 339 // Store the _pixel_ size in the font. Since QFont::setPixelSize() only takes an int, call 340 340 // QFont::SetPointSize() instead. Set proper font size just before rendering. 341 m_qfont.setPointSize (size);341 m_qfont.setPointSizeF(size); 342 342 m_sizeSet = 1; 343 343 } … … 411 411 public: 412 412 QSvgStrokeStyle(); 413 virtual void apply(QPainter *p, const Q RectF &, QSvgNode *node, QSvgExtraStates &states);413 virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states); 414 414 virtual void revert(QPainter *p, QSvgExtraStates &states); 415 415 virtual Type type() const; … … 618 618 public: 619 619 QSvgTransformStyle(const QTransform &transform); 620 virtual void apply(QPainter *p, const Q RectF &, QSvgNode *node, QSvgExtraStates &states);620 virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states); 621 621 virtual void revert(QPainter *p, QSvgExtraStates &states); 622 622 virtual Type type() const; … … 655 655 void setFreeze(bool freeze); 656 656 void setRepeatCount(qreal repeatCount); 657 virtual void apply(QPainter *p, const Q RectF &, QSvgNode *node, QSvgExtraStates &states);657 virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states); 658 658 virtual void revert(QPainter *p, QSvgExtraStates &states); 659 659 virtual Type type() const; … … 689 689 690 690 protected: 691 void resolveMatrix( QSvgNode *node);691 void resolveMatrix(const QSvgNode *node); 692 692 private: 693 693 qreal m_from, m_to, m_by; … … 713 713 void setFreeze(bool freeze); 714 714 void setRepeatCount(qreal repeatCount); 715 virtual void apply(QPainter *p, const Q RectF &, QSvgNode *node, QSvgExtraStates &states);715 virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states); 716 716 virtual void revert(QPainter *p, QSvgExtraStates &states); 717 717 virtual Type type() const; … … 733 733 public: 734 734 QSvgCompOpStyle(QPainter::CompositionMode mode); 735 virtual void apply(QPainter *p, const Q RectF &, QSvgNode *node, QSvgExtraStates &states);735 virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states); 736 736 virtual void revert(QPainter *p, QSvgExtraStates &states); 737 737 virtual Type type() const; … … 767 767 ~QSvgStyle(); 768 768 769 void apply(QPainter *p, const Q RectF &rect, QSvgNode *node, QSvgExtraStates &states);769 void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states); 770 770 void revert(QPainter *p, QSvgExtraStates &states); 771 771 QSvgRefCounter<QSvgQualityStyle> quality; -
trunk/src/svg/qsvgtinydocument.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 278 278 p->save(); 279 279 280 const QRectF elementBounds = node->transformedBounds( QTransform());280 const QRectF elementBounds = node->transformedBounds(); 281 281 282 282 mapSourceToTarget(p, bounds, elementBounds); … … 300 300 for (int i = parentApplyStack.size() - 1; i >= 0; --i) 301 301 parentApplyStack[i]->applyStyle(p, m_states); 302 302 303 303 // Reset the world transform so that our parents don't affect 304 304 // the position … … 433 433 if (!node) 434 434 node = this; 435 436 return node->transformedBounds(QTransform()); 435 return node->transformedBounds(); 437 436 } 438 437 -
trunk/src/svg/qsvgtinydocument_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 174 174 inline QRectF QSvgTinyDocument::viewBox() const 175 175 { 176 if (m_viewBox.isNull()) { 177 m_viewBox = transformedBounds(QTransform()); 178 } 176 if (m_viewBox.isNull()) 177 m_viewBox = transformedBounds(); 179 178 180 179 return m_viewBox; -
trunk/src/svg/qsvgwidget.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/svg/qsvgwidget.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/svg/svg.pro
r561 r846 43 43 symbian:TARGET.UID3=0x2001B2E2 44 44 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 } 45 include(../3rdparty/zlib_dependency.pri)
Note:
See TracChangeset
for help on using the changeset viewer.