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/svg/qsvgstyle.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 QtSvg 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**
     
    6060QSvgExtraStates::QSvgExtraStates()
    6161    : fillOpacity(1.0)
     62    , strokeOpacity(1.0)
     63    , svgFont(0)
     64    , textAnchor(Qt::AlignLeft)
     65    , fontWeight(400)
     66    , fillRule(Qt::WindingFill)
     67    , strokeDashOffset(0)
     68    , vectorEffect(false)
    6269{
    6370}
     
    6673{
    6774}
     75
     76void QSvgFillStyleProperty::apply(QPainter *, const QRectF &, QSvgNode *, QSvgExtraStates &)
     77{
     78    Q_ASSERT(!"This should not be called!");
     79}
     80
     81void QSvgFillStyleProperty::revert(QPainter *, QSvgExtraStates &)
     82{
     83    Q_ASSERT(!"This should not be called!");
     84}
     85
    6886
    6987QSvgQualityStyle::QSvgQualityStyle(int color)
     
    8199}
    82100
    83 QSvgFillStyle::QSvgFillStyle(const QBrush &brush)
    84     : m_fill(brush), m_style(0), m_fillRuleSet(false), m_fillOpacitySet(false)
    85 {
    86 }
    87 
    88 QSvgFillStyle::QSvgFillStyle(QSvgStyleProperty *style)
    89     : m_style(style), m_fillRuleSet(false), m_fillOpacitySet(false)
     101QSvgFillStyle::QSvgFillStyle()
     102    : m_style(0)
     103    , m_fillRule(Qt::WindingFill)
     104    , m_oldFillRule(Qt::WindingFill)
     105    , m_fillOpacity(1.0)
     106    , m_oldFillOpacity(0)
     107    , m_gradientResolved(1)
     108    , m_fillRuleSet(0)
     109    , m_fillOpacitySet(0)
     110    , m_fillSet(0)
    90111{
    91112}
     
    93114void QSvgFillStyle::setFillRule(Qt::FillRule f)
    94115{
    95     m_fillRuleSet = true;
     116    m_fillRuleSet = 1;
    96117    m_fillRule = f;
    97118}
     
    99120void QSvgFillStyle::setFillOpacity(qreal opacity)
    100121{
    101     m_fillOpacitySet = true;
     122    m_fillOpacitySet = 1;
    102123    m_fillOpacity = opacity;
    103124}
    104125
    105 static void recursivelySetFill(QSvgNode *node, Qt::FillRule f)
    106 {
    107     if (node->type() == QSvgNode::PATH) {
    108         QSvgPath *path = static_cast<QSvgPath*>(node);
    109         path->qpath()->setFillRule(f);
    110     } else if (node->type() == QSvgNode::G) {
    111         QList<QSvgNode*> renderers = static_cast<QSvgG*>(node)->renderers();
    112         foreach(QSvgNode *n, renderers) {
    113             recursivelySetFill(n, f);
    114         }
    115     }
    116 }
    117 void QSvgFillStyle::apply(QPainter *p, const QRectF &rect, QSvgNode *node, QSvgExtraStates &states)
     126void QSvgFillStyle::setFillStyle(QSvgFillStyleProperty* style)
     127{
     128    m_style = style;
     129    m_fillSet = 1;
     130}
     131
     132void QSvgFillStyle::setBrush(QBrush brush)
     133{
     134    m_fill = brush;
     135    m_style = 0;
     136    m_fillSet = 1;
     137}
     138
     139void QSvgFillStyle::apply(QPainter *p, const QRectF &, QSvgNode *, QSvgExtraStates &states)
    118140{
    119141    m_oldFill = p->brush();
    120     m_oldOpacity = states.fillOpacity;
    121 
    122     if (m_fillRuleSet) {
    123         recursivelySetFill(node, m_fillRule);
    124         m_fillRuleSet = false;//set it only on the first run
    125     }
    126     p->setBrush(m_fill);
     142    m_oldFillRule = states.fillRule;
     143    m_oldFillOpacity = states.fillOpacity;
     144
     145    if (m_fillRuleSet)
     146        states.fillRule = m_fillRule;
     147    if (m_fillSet) {
     148        if (m_style)
     149            p->setBrush(m_style->brush(p, states));
     150        else
     151            p->setBrush(m_fill);
     152    }
    127153    if (m_fillOpacitySet)
    128154        states.fillOpacity = m_fillOpacity;
    129     if (m_style)
    130         m_style->apply(p, rect, node, states);
    131155}
    132156
    133157void QSvgFillStyle::revert(QPainter *p, QSvgExtraStates &states)
    134158{
    135     if (m_style)
    136         m_style->revert(p, states);
    137     p->setBrush(m_oldFill);
    138159    if (m_fillOpacitySet)
    139         states.fillOpacity = m_oldOpacity;
     160        states.fillOpacity = m_oldFillOpacity;
     161    if (m_fillSet)
     162        p->setBrush(m_oldFill);
     163    if (m_fillRuleSet)
     164        states.fillRule = m_oldFillRule;
    140165}
    141166
     
    157182
    158183QSvgFontStyle::QSvgFontStyle(QSvgFont *font, QSvgTinyDocument *doc)
    159     : m_font(font), m_pointSize(24), m_doc(doc)
    160 {
    161 }
    162 
    163 QSvgFontStyle::QSvgFontStyle(const QFont &font, QSvgTinyDocument *doc)
    164     : m_font(0), m_pointSize(24), m_doc(doc), m_qfont(font)
    165 {
    166 }
    167 
    168 
    169 void QSvgFontStyle::setPointSize(qreal size)
    170 {
    171     m_pointSize = size;
    172 }
    173 
    174 qreal QSvgFontStyle::pointSize() const
    175 {
    176     return m_pointSize;
    177 }
    178 
    179 void QSvgFontStyle::apply(QPainter *p, const QRectF &, QSvgNode *, QSvgExtraStates &)
    180 {
    181     if (!m_font) {
    182         m_oldFont = p->font();
    183         p->setFont(m_qfont);
    184     }
    185 }
    186 
    187 void QSvgFontStyle::revert(QPainter *p, QSvgExtraStates &)
    188 {
    189     if (!m_font) {
    190         p->setFont(m_oldFont);
    191     }
    192 }
    193 
    194 QSvgStrokeStyle::QSvgStrokeStyle(const QPen &pen)
    195     : m_stroke(pen)
    196 {
    197 }
    198 
    199 void QSvgStrokeStyle::apply(QPainter *p, const QRectF &, QSvgNode *, QSvgExtraStates &)
     184    : m_svgFont(font)
     185    , m_doc(doc)
     186    , m_familySet(0)
     187    , m_sizeSet(0)
     188    , m_styleSet(0)
     189    , m_variantSet(0)
     190    , m_weightSet(0)
     191    , m_textAnchorSet(0)
     192{
     193}
     194
     195QSvgFontStyle::QSvgFontStyle()
     196    : m_svgFont(0)
     197    , m_doc(0)
     198    , m_familySet(0)
     199    , m_sizeSet(0)
     200    , m_styleSet(0)
     201    , m_variantSet(0)
     202    , m_weightSet(0)
     203    , m_textAnchorSet(0)
     204{
     205}
     206
     207int QSvgFontStyle::SVGToQtWeight(int weight) {
     208    switch (weight) {
     209    case 100:
     210    case 200:
     211        return QFont::Light;
     212    case 300:
     213    case 400:
     214        return QFont::Normal;
     215    case 500:
     216    case 600:
     217        return QFont::DemiBold;
     218    case 700:
     219    case 800:
     220        return QFont::Bold;
     221    case 900:
     222        return QFont::Black;
     223    }
     224    return QFont::Normal;
     225}
     226
     227void QSvgFontStyle::apply(QPainter *p, const QRectF &, QSvgNode *, QSvgExtraStates &states)
     228{
     229    m_oldQFont = p->font();
     230    m_oldSvgFont = states.svgFont;
     231    m_oldTextAnchor = states.textAnchor;
     232    m_oldWeight = states.fontWeight;
     233
     234    if (m_textAnchorSet)
     235        states.textAnchor = m_textAnchor;
     236
     237    QFont font = m_oldQFont;
     238    if (m_familySet) {
     239        states.svgFont = m_svgFont;
     240        font.setFamily(m_qfont.family());
     241    }
     242
     243    if (m_sizeSet)
     244        font.setPointSize(m_qfont.pointSizeF());
     245
     246    if (m_styleSet)
     247        font.setStyle(m_qfont.style());
     248
     249    if (m_variantSet)
     250        font.setCapitalization(m_qfont.capitalization());
     251
     252    if (m_weightSet) {
     253        if (m_weight == BOLDER) {
     254            states.fontWeight = qMin(states.fontWeight + 100, 900);
     255        } else if (m_weight == LIGHTER) {
     256            states.fontWeight = qMax(states.fontWeight - 100, 100);
     257        } else {
     258            states.fontWeight = m_weight;
     259        }
     260        font.setWeight(SVGToQtWeight(states.fontWeight));
     261    }
     262
     263    p->setFont(font);
     264}
     265
     266void QSvgFontStyle::revert(QPainter *p, QSvgExtraStates &states)
     267{
     268    p->setFont(m_oldQFont);
     269    states.svgFont = m_oldSvgFont;
     270    states.textAnchor = m_oldTextAnchor;
     271    states.fontWeight = m_oldWeight;
     272}
     273
     274QSvgStrokeStyle::QSvgStrokeStyle()
     275    : m_strokeOpacity(1.0)
     276    , m_oldStrokeOpacity(0.0)
     277    , m_strokeDashOffset(0)
     278    , m_oldStrokeDashOffset(0)
     279    , m_style(0)
     280    , m_gradientResolved(1)
     281    , m_vectorEffect(0)
     282    , m_oldVectorEffect(0)
     283    , m_strokeSet(0)
     284    , m_strokeDashArraySet(0)
     285    , m_strokeDashOffsetSet(0)
     286    , m_strokeLineCapSet(0)
     287    , m_strokeLineJoinSet(0)
     288    , m_strokeMiterLimitSet(0)
     289    , m_strokeOpacitySet(0)
     290    , m_strokeWidthSet(0)
     291    , m_vectorEffectSet(0)
     292{
     293}
     294
     295void QSvgStrokeStyle::apply(QPainter *p, const QRectF &, QSvgNode *, QSvgExtraStates &states)
    200296{
    201297    m_oldStroke = p->pen();
    202     p->setPen(m_stroke);
    203 }
    204 
    205 void QSvgStrokeStyle::revert(QPainter *p, QSvgExtraStates &)
     298    m_oldStrokeOpacity = states.strokeOpacity;
     299    m_oldStrokeDashOffset = states.strokeDashOffset;
     300    m_oldVectorEffect = states.vectorEffect;
     301
     302    QPen pen = p->pen();
     303
     304    qreal oldWidth = pen.widthF();
     305    qreal width = m_stroke.widthF();
     306    if (oldWidth == 0)
     307        oldWidth = 1;
     308    if (width == 0)
     309        width = 1;
     310    qreal scale = oldWidth / width;
     311
     312    if (m_strokeOpacitySet)
     313        states.strokeOpacity = m_strokeOpacity;
     314
     315    if (m_vectorEffectSet)
     316        states.vectorEffect = m_vectorEffect;
     317
     318    if (m_strokeSet) {
     319        if (m_style)
     320            pen.setBrush(m_style->brush(p, states));
     321        else
     322            pen.setBrush(m_stroke.brush());
     323    }
     324
     325    if (m_strokeWidthSet)
     326        pen.setWidthF(m_stroke.widthF());
     327
     328    bool setDashOffsetNeeded = false;
     329
     330    if (m_strokeDashOffsetSet) {
     331        states.strokeDashOffset = m_strokeDashOffset;
     332        setDashOffsetNeeded = true;
     333    }
     334
     335    if (m_strokeDashArraySet) {
     336        if (m_stroke.style() == Qt::SolidLine) {
     337            pen.setStyle(Qt::SolidLine);
     338        } else if (m_strokeWidthSet || oldWidth == 1) {
     339            // If both width and dash array was set, the dash array is already scaled correctly.
     340            pen.setDashPattern(m_stroke.dashPattern());
     341            setDashOffsetNeeded = true;
     342        } else {
     343            // If dash array was set, but not the width, the dash array has to be scaled with respect to the old width.
     344            QVector<qreal> dashes = m_stroke.dashPattern();
     345            for (int i = 0; i < dashes.size(); ++i)
     346                dashes[i] /= oldWidth;
     347            pen.setDashPattern(dashes);
     348            setDashOffsetNeeded = true;
     349        }
     350    } else if (m_strokeWidthSet && pen.style() != Qt::SolidLine && scale != 1) {
     351        // If the width was set, but not the dash array, the old dash array must be scaled with respect to the new width.
     352        QVector<qreal> dashes = pen.dashPattern();
     353        for (int i = 0; i < dashes.size(); ++i)
     354            dashes[i] *= scale;
     355        pen.setDashPattern(dashes);
     356        setDashOffsetNeeded = true;
     357    }
     358
     359    if (m_strokeLineCapSet)
     360        pen.setCapStyle(m_stroke.capStyle());
     361    if (m_strokeLineJoinSet)
     362        pen.setJoinStyle(m_stroke.joinStyle());
     363    if (m_strokeMiterLimitSet)
     364        pen.setMiterLimit(m_stroke.miterLimit());
     365
     366    // You can have dash offset on solid strokes in SVG files, but not in Qt.
     367    // QPen::setDashOffset() will set the pen style to Qt::CustomDashLine,
     368    // so don't call the method if the pen is solid.
     369    if (setDashOffsetNeeded && pen.style() != Qt::SolidLine) {
     370        qreal currentWidth = pen.widthF();
     371        if (currentWidth == 0)
     372            currentWidth = 1;
     373        pen.setDashOffset(states.strokeDashOffset / currentWidth);
     374    }
     375
     376    pen.setCosmetic(states.vectorEffect);
     377
     378    p->setPen(pen);
     379}
     380
     381void QSvgStrokeStyle::revert(QPainter *p, QSvgExtraStates &states)
    206382{
    207383    p->setPen(m_oldStroke);
     384    states.strokeOpacity = m_oldStrokeOpacity;
     385    states.strokeDashOffset = m_oldStrokeDashOffset;
     386    states.vectorEffect = m_oldVectorEffect;
     387}
     388
     389void QSvgStrokeStyle::setDashArray(const QVector<qreal> &dashes)
     390{
     391    if (m_strokeWidthSet) {
     392        QVector<qreal> d = dashes;
     393        qreal w = m_stroke.widthF();
     394        if (w != 0 && w != 1) {
     395            for (int i = 0; i < d.size(); ++i)
     396                d[i] /= w;
     397        }
     398        m_stroke.setDashPattern(d);
     399    } else {
     400        m_stroke.setDashPattern(dashes);
     401    }
     402    m_strokeDashArraySet = 1;
    208403}
    209404
     
    213408}
    214409
    215 void QSvgSolidColorStyle::apply(QPainter *p, const QRectF &, QSvgNode *, QSvgExtraStates &)
    216 {
    217     m_oldFill = p->brush();
    218     m_oldStroke = p->pen();
    219     QBrush b = m_oldFill;
    220     b.setColor(m_solidColor);
    221     p->setBrush(b);
    222     QPen pen = m_oldStroke;
    223     pen.setColor(m_solidColor);
    224     p->setPen(pen);
    225 }
    226 
    227 void QSvgSolidColorStyle::revert(QPainter *p, QSvgExtraStates &)
    228 {
    229     p->setBrush(m_oldFill);
    230     p->setPen(m_oldStroke);
    231 }
    232 
    233410QSvgGradientStyle::QSvgGradientStyle(QGradient *grad)
    234411    : m_gradient(grad), m_gradientStopsSet(false)
     
    236413}
    237414
    238 void QSvgGradientStyle::apply(QPainter *p, const QRectF &/*rect*/, QSvgNode *, QSvgExtraStates &)
     415QBrush QSvgGradientStyle::brush(QPainter *, QSvgExtraStates &)
    239416{
    240417    if (!m_link.isEmpty()) {
    241418        resolveStops();
    242     }
    243 
    244     m_oldFill = p->brush();
    245 
    246     //resolving stop colors
    247     if (!m_resolvePoints.isEmpty()) {
    248         QColor color = p->brush().color();
    249         if (!color.isValid())
    250             color = p->pen().color();
    251         QList<qreal>::const_iterator itr = m_resolvePoints.constBegin();
    252         for (; itr != m_resolvePoints.constEnd(); ++itr) {
    253             //qDebug()<<"resolving "<<(*itr)<<" to "<<color;
    254             m_gradient->setColorAt(*itr, color);
    255         }
    256419    }
    257420
     
    262425    }
    263426
    264     QBrush brush;
    265     brush = QBrush(*m_gradient);
     427    QBrush b(*m_gradient);
    266428
    267429    if (!m_matrix.isIdentity())
    268         brush.setMatrix(m_matrix);
    269 
    270     p->setBrush(brush);
    271 }
    272 
    273 void QSvgGradientStyle::revert(QPainter *p, QSvgExtraStates &)
    274 {
    275     p->setBrush(m_oldFill);
     430        b.setMatrix(m_matrix);
     431
     432    return b;
    276433}
    277434
     
    280437{
    281438    m_matrix = mat;
    282 }
    283 
    284 void QSvgGradientStyle::addResolve(qreal offset)
    285 {
    286     m_resolvePoints.append(offset);
    287439}
    288440
     
    390542    if (stroke) {
    391543        stroke->apply(p, rect, node, states);
    392     }
    393 
    394     if (solidColor) {
    395         solidColor->apply(p, rect, node, states);
    396     }
    397 
    398     if (gradient) {
    399         gradient->apply(p, rect, node, states);
    400544    }
    401545
     
    411555    //_after_ the original object transformations
    412556    if (!animateTransforms.isEmpty()) {
    413         QList<QSvgRefCounter<QSvgAnimateTransform> >::const_iterator itr;
    414         for (itr = animateTransforms.constBegin(); itr != animateTransforms.constEnd();
    415              ++itr) {
    416             (*itr)->apply(p, rect, node, states);
     557        qreal totalTimeElapsed = node->document()->currentElapsed();
     558        // Find the last animateTransform with additive="replace", since this will override all
     559        // previous animateTransforms.
     560        QList<QSvgRefCounter<QSvgAnimateTransform> >::const_iterator itr = animateTransforms.constEnd();
     561        do {
     562            --itr;
     563            if ((*itr)->animActive(totalTimeElapsed)
     564                && (*itr)->additiveType() == QSvgAnimateTransform::Replace) {
     565                // An animateTransform with additive="replace" will replace the transform attribute.
     566                if (transform)
     567                    transform->revert(p, states);
     568                break;
     569            }
     570        } while (itr != animateTransforms.constBegin());
     571
     572        // Apply the animateTransforms after and including the last one with additive="replace".
     573        for (; itr != animateTransforms.constEnd(); ++itr) {
     574            if ((*itr)->animActive(totalTimeElapsed))
     575                (*itr)->apply(p, rect, node, states);
    417576        }
    418577    }
     
    447606    if (stroke) {
    448607        stroke->revert(p, states);
    449     }
    450 
    451     if (solidColor) {
    452         solidColor->revert(p, states);
    453     }
    454 
    455     if (gradient) {
    456         gradient->revert(p, states);
    457608    }
    458609
     
    460611    //the native transforms
    461612    if (!animateTransforms.isEmpty()) {
    462         QList<QSvgRefCounter<QSvgAnimateTransform> >::const_iterator itr;
    463         itr = animateTransforms.constBegin();
    464         //only need to rever the first one because that
    465         //one has the original world matrix for the primitve
    466         if (itr != animateTransforms.constEnd()) {
    467             (*itr)->revert(p, states);
     613        QList<QSvgRefCounter<QSvgAnimateTransform> >::const_iterator itr = animateTransforms.constBegin();
     614        for (; itr != animateTransforms.constEnd(); ++itr) {
     615            if ((*itr)->transformApplied()) {
     616                (*itr)->revert(p, states);
     617                break;
     618            }
    468619        }
     620        for (; itr != animateTransforms.constEnd(); ++itr)
     621            (*itr)->clearTransformApplied();
    469622    }
    470623
     
    489642    : QSvgStyleProperty(),
    490643      m_from(startMs), m_to(endMs), m_by(byMs),
    491       m_type(Empty), m_count(0), m_finished(false)
     644      m_type(Empty), m_additive(Replace), m_count(0), m_finished(false), m_transformApplied(false)
    492645{
    493646    m_totalRunningTime = m_to - m_from;
    494647}
    495648
    496 void QSvgAnimateTransform::setArgs(TransformType type, const QVector<qreal> &args)
     649void QSvgAnimateTransform::setArgs(TransformType type, Additive additive, const QVector<qreal> &args)
    497650{
    498651    m_type = type;
    499652    m_args = args;
     653    m_additive = additive;
    500654    Q_ASSERT(!(args.count()%3));
    501655    m_count = args.count() / 3;
     
    506660    m_oldWorldTransform = p->worldTransform();
    507661    resolveMatrix(node);
    508     if (!m_finished || m_freeze)
    509         p->setWorldTransform(m_transform, true);
     662    p->setWorldTransform(m_transform, true);
     663    m_transformApplied = true;
    510664}
    511665
    512666void QSvgAnimateTransform::revert(QPainter *p, QSvgExtraStates &)
    513667{
    514     if (!m_finished || m_freeze) {
    515         p->setWorldTransform(m_oldWorldTransform, false /* don't combine */);
    516     }
     668    p->setWorldTransform(m_oldWorldTransform, false /* don't combine */);
     669    m_transformApplied = false;
    517670}
    518671
     
    524677        return;
    525678
    526     qreal animationFrame = (totalTimeElapsed - m_from) / m_to;
    527 
    528     if (m_repeatCount >= 0 && m_repeatCount < animationFrame) {
    529         m_finished = true;
    530         animationFrame = m_repeatCount;
     679    qreal animationFrame = 0;
     680    if (m_totalRunningTime != 0) {
     681        animationFrame = (totalTimeElapsed - m_from) / m_totalRunningTime;
     682
     683        if (m_repeatCount >= 0 && m_repeatCount < animationFrame) {
     684            m_finished = true;
     685            animationFrame = m_repeatCount;
     686        }
    531687    }
    532688
     
    545701        startElem *= 3;
    546702        endElem   *= 3;
    547         qreal from1, from2, from3;
    548         qreal to1, to2, to3;
     703        qreal from1, from2;
     704        qreal to1, to2;
    549705        from1 = m_args[startElem++];
    550706        from2 = m_args[startElem++];
    551         from3 = m_args[startElem++];
    552707        to1   = m_args[endElem++];
    553708        to2   = m_args[endElem++];
    554         to3   = m_args[endElem++];
    555709
    556710        qreal transXDiff = (to1-from1) * percentOfAnimation;
     
    565719        startElem *= 3;
    566720        endElem   *= 3;
    567         qreal from1, from2, from3;
    568         qreal to1, to2, to3;
     721        qreal from1, from2;
     722        qreal to1, to2;
    569723        from1 = m_args[startElem++];
    570724        from2 = m_args[startElem++];
    571         from3 = m_args[startElem++];
    572725        to1   = m_args[endElem++];
    573726        to2   = m_args[endElem++];
    574         to3   = m_args[endElem++];
    575727
    576728        qreal transXDiff = (to1-from1) * percentOfAnimation;
     
    612764        startElem *= 3;
    613765        endElem   *= 3;
    614         qreal from1, from2, from3;
    615         qreal to1, to2, to3;
     766        qreal from1;
     767        qreal to1;
    616768        from1 = m_args[startElem++];
    617         from2 = m_args[startElem++];
    618         from3 = m_args[startElem++];
    619769        to1   = m_args[endElem++];
    620         to2   = m_args[endElem++];
    621         to3   = m_args[endElem++];
    622770
    623771        qreal transXDiff = (to1-from1) * percentOfAnimation;
    624772        qreal transX = from1 + transXDiff;
    625773        m_transform = QTransform();
    626         m_transform.shear(tan(transX * deg2rad), 0);
     774        m_transform.shear(qTan(transX * deg2rad), 0);
    627775        break;
    628776    }
     
    630778        startElem *= 3;
    631779        endElem   *= 3;
    632         qreal from1, from2, from3;
    633         qreal to1, to2, to3;
     780        qreal from1;
     781        qreal to1;
    634782        from1 = m_args[startElem++];
    635         from2 = m_args[startElem++];
    636         from3 = m_args[startElem++];
    637783        to1   = m_args[endElem++];
    638         to2   = m_args[endElem++];
    639         to3   = m_args[endElem++];
    640784
    641785
     
    643787        qreal transY = from1 + transYDiff;
    644788        m_transform = QTransform();
    645         m_transform.shear(0, tan(transY * deg2rad));
     789        m_transform.shear(0, qTan(transY * deg2rad));
    646790        break;
    647791    }
     
    697841        return;
    698842
    699     qreal animationFrame = (totalTimeElapsed - m_from) / m_to;
     843    qreal animationFrame = 0;
     844    if (m_totalRunningTime != 0)
     845        animationFrame = (totalTimeElapsed - m_from) / m_totalRunningTime;
    700846
    701847    if (m_repeatCount >= 0 && m_repeatCount < animationFrame) {
     
    761907}
    762908
    763 QString QSvgFontStyle::textAnchor() const
    764 {
    765     return m_textAnchor;
    766 }
    767 
    768 void QSvgFontStyle::setTextAnchor(const QString &anchor)
    769 {
    770     m_textAnchor = anchor;
    771 }
    772 
    773909QSvgOpacityStyle::QSvgOpacityStyle(qreal opacity)
    774     : m_opacity(opacity)
     910    : m_opacity(opacity), m_oldOpacity(0)
    775911{
    776912
     
    802938{
    803939    if (!m_link.isEmpty() && m_doc) {
    804         QSvgStyleProperty *prop = m_doc->scopeStyle(m_link);
     940        QSvgStyleProperty *prop = m_doc->styleProperty(m_link);
    805941        if (prop) {
    806942            if (prop->type() == QSvgStyleProperty::GRADIENT) {
     
    809945                st->resolveStops();
    810946                m_gradient->setStops(st->qgradient()->stops());
     947                m_gradientStopsSet = st->gradientStopsSet();
    811948            }
     949        } else {
     950            qWarning("Could not resolve property : %s", qPrintable(m_link));
    812951        }
    813952        m_link = QString();
Note: See TracChangeset for help on using the changeset viewer.