Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qsvgstyle.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qsvgstyle_p.h"
5
6#include "qsvgfont_p.h"
8#include "qsvgnode_p.h"
9#include "private/qsvganimate_p.h"
11
12#include "qpainter.h"
13#include "qpair.h"
14#include "qcolor.h"
15#include "qdebug.h"
16#include "qmath.h"
17#include "qnumeric.h"
18
20
21QSvgExtraStates::QSvgExtraStates()
22 : fillOpacity(1.0),
23 strokeOpacity(1.0),
24 svgFont(0),
25 textAnchor(Qt::AlignLeft),
26 fontWeight(QFont::Normal),
27 fillRule(Qt::WindingFill),
28 strokeDashOffset(0),
29 vectorEffect(false),
30 imageRendering(QSvgQualityStyle::ImageRenderingAuto)
31{
32}
33
34QSvgStyleProperty::~QSvgStyleProperty()
35{
36}
37
38void QSvgPaintStyleProperty::apply(QPainter *, const QSvgNode *, QSvgExtraStates &)
39{
40 Q_ASSERT(!"This should not be called!");
41}
42
43void QSvgPaintStyleProperty::revert(QPainter *, QSvgExtraStates &)
44{
45 Q_ASSERT(!"This should not be called!");
46}
47
48
49QSvgQualityStyle::QSvgQualityStyle(int color)
50 : m_imageRendering(QSvgQualityStyle::ImageRenderingAuto)
51 , m_oldImageRendering(QSvgQualityStyle::ImageRenderingAuto)
52 , m_imageRenderingSet(0)
53{
54 Q_UNUSED(color);
55}
56
57void QSvgQualityStyle::setImageRendering(ImageRendering hint) {
58 m_imageRendering = hint;
59 m_imageRenderingSet = 1;
60}
61
62void QSvgQualityStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &states)
63{
64 m_oldImageRendering = states.imageRendering;
65 if (m_imageRenderingSet) {
66 states.imageRendering = m_imageRendering;
67 }
68 if (m_imageRenderingSet) {
69 bool smooth = false;
70 if (m_imageRendering == ImageRenderingAuto)
71 // auto (the spec says to prefer quality)
72 smooth = true;
73 else
74 smooth = (m_imageRendering == ImageRenderingOptimizeQuality);
75 p->setRenderHint(QPainter::SmoothPixmapTransform, smooth);
76 }
77}
78
79void QSvgQualityStyle::revert(QPainter *p, QSvgExtraStates &states)
80{
81 if (m_imageRenderingSet) {
82 states.imageRendering = m_oldImageRendering;
83 bool smooth = false;
84 if (m_oldImageRendering == ImageRenderingAuto)
85 smooth = true;
86 else
87 smooth = (m_oldImageRendering == ImageRenderingOptimizeQuality);
88 p->setRenderHint(QPainter::SmoothPixmapTransform, smooth);
89 }
90}
91
92QSvgFillStyle::QSvgFillStyle()
93 : m_style(0)
94 , m_fillRule(Qt::WindingFill)
95 , m_oldFillRule(Qt::WindingFill)
96 , m_fillOpacity(1.0)
97 , m_oldFillOpacity(0)
98 , m_paintStyleResolved(1)
99 , m_fillRuleSet(0)
100 , m_fillOpacitySet(0)
101 , m_fillSet(0)
102{
103}
104
105void QSvgFillStyle::setFillRule(Qt::FillRule f)
106{
107 m_fillRuleSet = 1;
108 m_fillRule = f;
109}
110
111void QSvgFillStyle::setFillOpacity(qreal opacity)
112{
113 m_fillOpacitySet = 1;
114 m_fillOpacity = opacity;
115}
116
117void QSvgFillStyle::setFillStyle(QSvgPaintStyleProperty* style)
118{
119 m_style = style;
120 m_fillSet = 1;
121}
122
123void QSvgFillStyle::setBrush(QBrush brush)
124{
125 m_fill = std::move(brush);
126 m_style = nullptr;
127 m_fillSet = 1;
128}
129
130void QSvgFillStyle::apply(QPainter *p, const QSvgNode *n, QSvgExtraStates &states)
131{
132 m_oldFill = p->brush();
133 m_oldFillRule = states.fillRule;
134 m_oldFillOpacity = states.fillOpacity;
135
136 if (m_fillRuleSet)
137 states.fillRule = m_fillRule;
138 if (m_fillSet) {
139 if (m_style)
140 p->setBrush(m_style->brush(p, n, states));
141 else
142 p->setBrush(m_fill);
143 }
144 if (m_fillOpacitySet)
145 states.fillOpacity = m_fillOpacity;
146}
147
148void QSvgFillStyle::revert(QPainter *p, QSvgExtraStates &states)
149{
150 if (m_fillOpacitySet)
151 states.fillOpacity = m_oldFillOpacity;
152 if (m_fillSet)
153 p->setBrush(m_oldFill);
154 if (m_fillRuleSet)
155 states.fillRule = m_oldFillRule;
156}
157
158QSvgViewportFillStyle::QSvgViewportFillStyle(const QBrush &brush)
159 : m_viewportFill(brush)
160{
161}
162
163void QSvgViewportFillStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &)
164{
165 m_oldFill = p->brush();
166 p->setBrush(m_viewportFill);
167}
168
169void QSvgViewportFillStyle::revert(QPainter *p, QSvgExtraStates &)
170{
171 p->setBrush(m_oldFill);
172}
173
174QSvgFontStyle::QSvgFontStyle(QSvgFont *font, QSvgTinyDocument *doc)
175 : m_svgFont(font)
176 , m_doc(doc)
177 , m_familySet(0)
178 , m_sizeSet(0)
179 , m_styleSet(0)
180 , m_variantSet(0)
181 , m_weightSet(0)
182 , m_textAnchorSet(0)
183{
184}
185
186QSvgFontStyle::QSvgFontStyle()
187 : m_svgFont(0)
188 , m_doc(0)
189 , m_familySet(0)
190 , m_sizeSet(0)
191 , m_styleSet(0)
192 , m_variantSet(0)
193 , m_weightSet(0)
194 , m_textAnchorSet(0)
195{
196}
197
198void QSvgFontStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &states)
199{
200 m_oldQFont = p->font();
201 m_oldSvgFont = states.svgFont;
202 m_oldTextAnchor = states.textAnchor;
203 m_oldWeight = states.fontWeight;
204
205 if (m_textAnchorSet)
206 states.textAnchor = m_textAnchor;
207
208 QFont font = m_oldQFont;
209 if (m_familySet) {
210 states.svgFont = m_svgFont;
211 font.setFamilies(m_qfont.families());
212 }
213
214 if (m_sizeSet)
215 font.setPointSizeF(m_qfont.pointSizeF());
216
217 if (m_styleSet)
218 font.setStyle(m_qfont.style());
219
220 if (m_variantSet)
221 font.setCapitalization(m_qfont.capitalization());
222
223 if (m_weightSet) {
224 if (m_weight == BOLDER) {
225 states.fontWeight = qMin(states.fontWeight + 100, static_cast<int>(QFont::Black));
226 } else if (m_weight == LIGHTER) {
227 states.fontWeight = qMax(states.fontWeight - 100, static_cast<int>(QFont::Thin));
228 } else {
229 states.fontWeight = m_weight;
230 }
231 font.setWeight(QFont::Weight(qBound(static_cast<int>(QFont::Weight::Thin),
232 states.fontWeight,
233 static_cast<int>(QFont::Weight::Black))));
234 }
235
236 p->setFont(font);
237}
238
239void QSvgFontStyle::revert(QPainter *p, QSvgExtraStates &states)
240{
241 p->setFont(m_oldQFont);
242 states.svgFont = m_oldSvgFont;
243 states.textAnchor = m_oldTextAnchor;
244 states.fontWeight = m_oldWeight;
245}
246
247QSvgStrokeStyle::QSvgStrokeStyle()
248 : m_strokeOpacity(1.0)
249 , m_oldStrokeOpacity(0.0)
250 , m_strokeDashOffset(0)
251 , m_oldStrokeDashOffset(0)
252 , m_style(0)
253 , m_paintStyleResolved(1)
254 , m_vectorEffect(0)
255 , m_oldVectorEffect(0)
256 , m_strokeSet(0)
257 , m_strokeDashArraySet(0)
258 , m_strokeDashOffsetSet(0)
259 , m_strokeLineCapSet(0)
260 , m_strokeLineJoinSet(0)
261 , m_strokeMiterLimitSet(0)
262 , m_strokeOpacitySet(0)
263 , m_strokeWidthSet(0)
264 , m_vectorEffectSet(0)
265{
266}
267
268void QSvgStrokeStyle::apply(QPainter *p, const QSvgNode *n, QSvgExtraStates &states)
269{
270 m_oldStroke = p->pen();
271 m_oldStrokeOpacity = states.strokeOpacity;
272 m_oldStrokeDashOffset = states.strokeDashOffset;
273 m_oldVectorEffect = states.vectorEffect;
274
275 QPen pen = p->pen();
276
277 qreal oldWidth = pen.widthF();
278 qreal width = m_stroke.widthF();
279 if (oldWidth == 0)
280 oldWidth = 1;
281 if (width == 0)
282 width = 1;
283 qreal scale = oldWidth / width;
284
285 if (m_strokeOpacitySet)
286 states.strokeOpacity = m_strokeOpacity;
287
288 if (m_vectorEffectSet)
289 states.vectorEffect = m_vectorEffect;
290
291 if (m_strokeSet) {
292 if (m_style)
293 pen.setBrush(m_style->brush(p, n, states));
294 else
295 pen.setBrush(m_stroke.brush());
296 }
297
298 if (m_strokeWidthSet)
299 pen.setWidthF(m_stroke.widthF());
300
301 bool setDashOffsetNeeded = false;
302
303 if (m_strokeDashOffsetSet) {
304 states.strokeDashOffset = m_strokeDashOffset;
305 setDashOffsetNeeded = true;
306 }
307
308 if (m_strokeDashArraySet) {
309 if (m_stroke.style() == Qt::SolidLine) {
310 pen.setStyle(Qt::SolidLine);
311 } else if (m_strokeWidthSet || oldWidth == 1) {
312 // If both width and dash array was set, the dash array is already scaled correctly.
313 pen.setDashPattern(m_stroke.dashPattern());
314 setDashOffsetNeeded = true;
315 } else {
316 // If dash array was set, but not the width, the dash array has to be scaled with respect to the old width.
317 QList<qreal> dashes = m_stroke.dashPattern();
318 for (int i = 0; i < dashes.size(); ++i)
319 dashes[i] /= oldWidth;
320 pen.setDashPattern(dashes);
321 setDashOffsetNeeded = true;
322 }
323 } else if (m_strokeWidthSet && pen.style() != Qt::SolidLine && scale != 1) {
324 // If the width was set, but not the dash array, the old dash array must be scaled with respect to the new width.
325 QList<qreal> dashes = pen.dashPattern();
326 for (int i = 0; i < dashes.size(); ++i)
327 dashes[i] *= scale;
328 pen.setDashPattern(dashes);
329 setDashOffsetNeeded = true;
330 }
331
332 if (m_strokeLineCapSet)
333 pen.setCapStyle(m_stroke.capStyle());
334 if (m_strokeLineJoinSet)
335 pen.setJoinStyle(m_stroke.joinStyle());
336 if (m_strokeMiterLimitSet)
337 pen.setMiterLimit(m_stroke.miterLimit());
338
339 // You can have dash offset on solid strokes in SVG files, but not in Qt.
340 // QPen::setDashOffset() will set the pen style to Qt::CustomDashLine,
341 // so don't call the method if the pen is solid.
342 if (setDashOffsetNeeded && pen.style() != Qt::SolidLine) {
343 qreal currentWidth = pen.widthF();
344 if (currentWidth == 0)
345 currentWidth = 1;
346 pen.setDashOffset(states.strokeDashOffset / currentWidth);
347 }
348
349 pen.setCosmetic(states.vectorEffect);
350
351 p->setPen(pen);
352}
353
354void QSvgStrokeStyle::revert(QPainter *p, QSvgExtraStates &states)
355{
356 p->setPen(m_oldStroke);
357 states.strokeOpacity = m_oldStrokeOpacity;
358 states.strokeDashOffset = m_oldStrokeDashOffset;
359 states.vectorEffect = m_oldVectorEffect;
360}
361
362void QSvgStrokeStyle::setDashArray(const QList<qreal> &dashes)
363{
364 if (m_strokeWidthSet) {
365 QList<qreal> d = dashes;
366 qreal w = m_stroke.widthF();
367 if (w != 0 && w != 1) {
368 for (int i = 0; i < d.size(); ++i)
369 d[i] /= w;
370 }
371 m_stroke.setDashPattern(d);
372 } else {
373 m_stroke.setDashPattern(dashes);
374 }
375 m_strokeDashArraySet = 1;
376}
377
378QSvgSolidColorStyle::QSvgSolidColorStyle(const QColor &color)
379 : m_solidColor(color)
380{
381}
382
383QSvgGradientStyle::QSvgGradientStyle(QGradient *grad)
384 : m_gradient(grad), m_gradientStopsSet(false)
385{
386}
387
388QBrush QSvgGradientStyle::brush(QPainter *, const QSvgNode *, QSvgExtraStates &)
389{
390 if (!m_link.isEmpty()) {
391 resolveStops();
392 }
393
394 // If the gradient is marked as empty, insert transparent black
395 if (!m_gradientStopsSet) {
396 m_gradient->setStops(QGradientStops() << QGradientStop(0.0, QColor(0, 0, 0, 0)));
397 m_gradientStopsSet = true;
398 }
399
400 QBrush b(*m_gradient);
401
402 if (!m_transform.isIdentity())
403 b.setTransform(m_transform);
404
405 return b;
406}
407
408
409void QSvgGradientStyle::setTransform(const QTransform &transform)
410{
411 m_transform = transform;
412}
413
414QSvgPatternStyle::QSvgPatternStyle(QSvgPattern *pattern)
415 : m_pattern(pattern)
416{
417
418}
419
420QBrush QSvgPatternStyle::brush(QPainter *p, const QSvgNode *node, QSvgExtraStates &states)
421{
422 QBrush b(m_pattern->patternImage(p, states, node));
423 b.setTransform(m_pattern->appliedTransform());
424 return b;
425}
426
427QSvgTransformStyle::QSvgTransformStyle(const QTransform &trans)
428 : m_transform(trans)
429{
430}
431
432void QSvgTransformStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &)
433{
434 m_oldWorldTransform.push(p->worldTransform());
435 p->setWorldTransform(m_transform, true);
436}
437
438void QSvgTransformStyle::revert(QPainter *p, QSvgExtraStates &)
439{
440 p->setWorldTransform(m_oldWorldTransform.pop(), false /* don't combine */);
441}
442
443QSvgStyleProperty::Type QSvgQualityStyle::type() const
444{
445 return QUALITY;
446}
447
448QSvgStyleProperty::Type QSvgFillStyle::type() const
449{
450 return FILL;
451}
452
453QSvgStyleProperty::Type QSvgViewportFillStyle::type() const
454{
455 return VIEWPORT_FILL;
456}
457
458QSvgStyleProperty::Type QSvgFontStyle::type() const
459{
460 return FONT;
461}
462
463QSvgStyleProperty::Type QSvgStrokeStyle::type() const
464{
465 return STROKE;
466}
467
468QSvgStyleProperty::Type QSvgSolidColorStyle::type() const
469{
470 return SOLID_COLOR;
471}
472
473QSvgStyleProperty::Type QSvgGradientStyle::type() const
474{
475 return GRADIENT;
476}
477
478QSvgStyleProperty::Type QSvgPatternStyle::type() const
479{
480 return PATTERN;
481}
482
483QSvgStyleProperty::Type QSvgTransformStyle::type() const
484{
485 return TRANSFORM;
486}
487
488
489QSvgCompOpStyle::QSvgCompOpStyle(QPainter::CompositionMode mode)
490 : m_mode(mode)
491{
492
493}
494
495void QSvgCompOpStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &)
496{
497 m_oldMode = p->compositionMode();
498 p->setCompositionMode(m_mode);
499}
500
501void QSvgCompOpStyle::revert(QPainter *p, QSvgExtraStates &)
502{
503 p->setCompositionMode(m_oldMode);
504}
505
506QSvgStyleProperty::Type QSvgCompOpStyle::type() const
507{
508 return COMP_OP;
509}
510
511QSvgOpacityStyle::QSvgOpacityStyle(qreal opacity)
512 : m_opacity(opacity), m_oldOpacity(0)
513{
514
515}
516
517void QSvgOpacityStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &)
518{
519 m_oldOpacity = p->opacity();
520 p->setOpacity(m_opacity * m_oldOpacity);
521}
522
523void QSvgOpacityStyle::revert(QPainter *p, QSvgExtraStates &)
524{
525 p->setOpacity(m_oldOpacity);
526}
527
528QSvgStyleProperty::Type QSvgOpacityStyle::type() const
529{
530 return OPACITY;
531}
532
533void QSvgGradientStyle::setStopLink(const QString &link, QSvgTinyDocument *doc)
534{
535 m_link = link;
536 m_doc = doc;
537}
538
539void QSvgGradientStyle::resolveStops()
540{
541 QStringList visited;
542 resolveStops_helper(&visited);
543}
544
545void QSvgGradientStyle::resolveStops_helper(QStringList *visited)
546{
547 if (!m_link.isEmpty() && m_doc) {
548 QSvgStyleProperty *prop = m_doc->styleProperty(m_link);
549 if (prop && !visited->contains(m_link)) {
550 visited->append(m_link);
551 if (prop->type() == QSvgStyleProperty::GRADIENT) {
552 QSvgGradientStyle *st =
553 static_cast<QSvgGradientStyle*>(prop);
554 st->resolveStops_helper(visited);
555 m_gradient->setStops(st->qgradient()->stops());
556 m_gradientStopsSet = st->gradientStopsSet();
557 }
558 } else {
559 qWarning("Could not resolve property : %s", qPrintable(m_link));
560 }
561 m_link = QString();
562 }
563}
564
565QSvgStaticStyle::QSvgStaticStyle()
566 : quality(0)
567 , fill(0)
568 , viewportFill(0)
569 , font(0)
570 , stroke(0)
571 , solidColor(0)
572 , gradient(0)
573 , pattern(0)
574 , transform(0)
575 , opacity(0)
576 , compop(0)
577{
578}
579
580QSvgStaticStyle::~QSvgStaticStyle()
581{
582}
583
584void QSvgStaticStyle::apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states)
585{
586 if (quality) {
587 quality->apply(p, node, states);
588 }
589
590 if (fill) {
591 fill->apply(p, node, states);
592 }
593
594 if (viewportFill) {
595 viewportFill->apply(p, node, states);
596 }
597
598 if (font) {
599 font->apply(p, node, states);
600 }
601
602 if (stroke) {
603 stroke->apply(p, node, states);
604 }
605
606 if (transform) {
607 transform->apply(p, node, states);
608 }
609
610 if (opacity) {
611 opacity->apply(p, node, states);
612 }
613
614 if (compop) {
615 compop->apply(p, node, states);
616 }
617}
618
619void QSvgStaticStyle::revert(QPainter *p, QSvgExtraStates &states)
620{
621 if (quality) {
622 quality->revert(p, states);
623 }
624
625 if (fill) {
626 fill->revert(p, states);
627 }
628
629 if (viewportFill) {
630 viewportFill->revert(p, states);
631 }
632
633 if (font) {
634 font->revert(p, states);
635 }
636
637 if (stroke) {
638 stroke->revert(p, states);
639 }
640
641 if (transform) {
642 transform->revert(p, states);
643 }
644
645 if (opacity) {
646 opacity->revert(p, states);
647 }
648
649 if (compop) {
650 compop->revert(p, states);
651 }
652}
653
654namespace {
655
656QColor sumValue(const QColor &c1, const QColor &c2)
657{
658 QRgb rgb1 = c1.rgba();
659 QRgb rgb2 = c2.rgba();
660 int sumRed = qRed(rgb1) + qRed(rgb2);
661 int sumGreen = qGreen(rgb1) + qGreen(rgb2);
662 int sumBlue = qBlue(rgb1) + qBlue(rgb2);
663
664 QRgb sumRgb = qRgba(qBound(0, sumRed, 255),
665 qBound(0, sumGreen, 255),
666 qBound(0, sumBlue, 255),
667 255);
668
669 return QColor(sumRgb);
670}
671
672qreal sumValue(qreal value1, qreal value2)
673{
674 qreal sumValue = value1 + value2;
675 return qBound(0.0, sumValue, 1.0);
676}
677
678}
679
680QSvgAnimatedStyle::QSvgAnimatedStyle()
681{
682}
683
684QSvgAnimatedStyle::~QSvgAnimatedStyle()
685{
686}
687
688void QSvgAnimatedStyle::apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states)
689{
690 QSharedPointer<QSvgAbstractAnimator> animator = node->document()->animator();
691 QList<QSvgAbstractAnimation *> nodeAnims = animator->animationsForNode(node);
692
693 savePaintingState(p, node, states);
694 if (nodeAnims.isEmpty())
695 return;
696
697 for (auto anim : nodeAnims) {
698 if (!anim->isActive())
699 continue;
700
701 bool replace = anim->animationType() == QSvgAbstractAnimation::CSS ? true :
702 (static_cast<QSvgAnimateNode *>(anim))->additiveType() == QSvgAnimateNode::Replace;
703 QList<QSvgAbstractAnimatedProperty *> props = anim->properties();
704 for (auto prop : props)
705 applyPropertyAnimation(p, prop, replace, states);
706 }
707}
708
709void QSvgAnimatedStyle::revert(QPainter *p, QSvgExtraStates &states)
710{
711 p->setWorldTransform(m_worldTransform, false);
712 p->setBrush(m_brush);
713 p->setPen(m_pen);
714 p->setOpacity(m_opacity);
715 states.fillOpacity = m_fillOpacity;
716 states.strokeOpacity = m_strokeOpacity;
717}
718
719void QSvgAnimatedStyle::savePaintingState(const QPainter *p, const QSvgNode *node, QSvgExtraStates &states)
720{
721 QSvgStaticStyle style = node->style();
722 m_worldTransform = m_transformToNode = p->worldTransform();
723 if (style.transform)
724 m_transformToNode = style.transform->qtransform().inverted() * m_transformToNode;
725
726 m_brush = p->brush();
727 m_pen = p->pen();
728 m_fillOpacity = states.fillOpacity;
729 m_strokeOpacity = states.strokeOpacity;
730 m_opacity = p->opacity();
731}
732
733void QSvgAnimatedStyle::applyPropertyAnimation(QPainter *p, QSvgAbstractAnimatedProperty *property,
734 bool replace, QSvgExtraStates &states)
735{
736 if (property->propertyName() == QStringLiteral("fill")) {
737 QBrush brush = p->brush();
738 QColor brushColor = brush.color();
739 QColor animatedColor = property->interpolatedValue().value<QColor>();
740 QColor sumOrReplaceColor = replace ? animatedColor : sumValue(brushColor, animatedColor);
741 brush.setColor(sumOrReplaceColor);
742 p->setBrush(brush);
743 } else if (property->propertyName() == QStringLiteral("stroke")) {
744 QPen pen = p->pen();
745 QBrush penBrush = pen.brush();
746 QColor penColor = penBrush.color();
747 QColor animatedColor = property->interpolatedValue().value<QColor>();
748 QColor sumOrReplaceColor = replace ? animatedColor : sumValue(penColor, animatedColor);
749 penBrush.setColor(sumOrReplaceColor);
750 penBrush.setStyle(Qt::SolidPattern);
751 pen.setBrush(penBrush);
752 p->setPen(pen);
753 } else if (property->propertyName() == QStringLiteral("transform")) {
754 QTransform animatedTransform = property->interpolatedValue().value<QTransform>();
755 QTransform sumOrReplaceTransform = replace ? animatedTransform * m_transformToNode :
756 animatedTransform * p->worldTransform();
757 p->setWorldTransform(sumOrReplaceTransform);
758 } else if (property->propertyName() == QStringLiteral("fill-opacity")) {
759 qreal animatedFillOpacity = property->interpolatedValue().value<qreal>();
760 qreal sumOrReplaceOpacity = replace ? animatedFillOpacity : sumValue(m_fillOpacity, animatedFillOpacity);
761 states.fillOpacity = sumOrReplaceOpacity;
762 } else if (property->propertyName() == QStringLiteral("stroke-opacity")) {
763 qreal animatedStrokeOpacity = property->interpolatedValue().value<qreal>();
764 qreal sumOrReplaceOpacity = replace ? animatedStrokeOpacity : sumValue(m_strokeOpacity, animatedStrokeOpacity);
765 states.strokeOpacity = sumOrReplaceOpacity;
766 } else if (property->propertyName() == QStringLiteral("opacity")) {
767 qreal animatedOpacity = property->interpolatedValue().value<qreal>();
768 qreal sumOrReplaceOpacity = replace ? animatedOpacity : sumValue(m_opacity, animatedOpacity);
769 p->setOpacity(sumOrReplaceOpacity);
770 }
771}
772
773QT_END_NAMESPACE
#define qPrintable(string)
Definition qstring.h:1685
#define QStringLiteral(str)
Definition qstring.h:1826