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:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • 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
Note: See TracChangeset for help on using the changeset viewer.