OSDN Git Service

SVG styles cleanup
authorIvailo Monev <xakepa10@laimg.moc>
Sat, 13 Jul 2019 20:57:44 +0000 (20:57 +0000)
committerIvailo Monev <xakepa10@laimg.moc>
Sat, 13 Jul 2019 20:57:44 +0000 (20:57 +0000)
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
src/svg/qsvgstyle.cpp
src/svg/qsvgstyle_p.h

index ee06440..2d3dbf2 100644 (file)
@@ -103,36 +103,36 @@ QSvgFillStyle::QSvgFillStyle()
     , m_oldFillRule(Qt::WindingFill)
     , m_fillOpacity(1.0)
     , m_oldFillOpacity(0)
-    , m_gradientResolved(1)
-    , m_fillRuleSet(0)
-    , m_fillOpacitySet(0)
-    , m_fillSet(0)
+    , m_gradientResolved(true)
+    , m_fillRuleSet(false)
+    , m_fillOpacitySet(false)
+    , m_fillSet(false)
 {
 }
 
 void QSvgFillStyle::setFillRule(Qt::FillRule f)
 {
-    m_fillRuleSet = 1;
+    m_fillRuleSet = true;
     m_fillRule = f;
 }
 
 void QSvgFillStyle::setFillOpacity(qreal opacity)
 {
-    m_fillOpacitySet = 1;
+    m_fillOpacitySet = true;
     m_fillOpacity = opacity;
 }
 
 void QSvgFillStyle::setFillStyle(QSvgFillStyleProperty* style)
 {
     m_style = style;
-    m_fillSet = 1;
+    m_fillSet = true;
 }
 
 void QSvgFillStyle::setBrush(QBrush brush)
 {
     m_fill = brush;
     m_style = 0;
-    m_fillSet = 1;
+    m_fillSet = true;
 }
 
 void QSvgFillStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &states)
@@ -182,24 +182,24 @@ void QSvgViewportFillStyle::revert(QPainter *p, QSvgExtraStates &)
 QSvgFontStyle::QSvgFontStyle(QSvgFont *font, QSvgTinyDocument *doc)
     : m_svgFont(font)
     , m_doc(doc)
-    , m_familySet(0)
-    , m_sizeSet(0)
-    , m_styleSet(0)
-    , m_variantSet(0)
-    , m_weightSet(0)
-    , m_textAnchorSet(0)
+    , m_familySet(false)
+    , m_sizeSet(false)
+    , m_styleSet(false)
+    , m_variantSet(false)
+    , m_weightSet(false)
+    , m_textAnchorSet(false)
 {
 }
 
 QSvgFontStyle::QSvgFontStyle()
     : m_svgFont(0)
     , m_doc(0)
-    , m_familySet(0)
-    , m_sizeSet(0)
-    , m_styleSet(0)
-    , m_variantSet(0)
-    , m_weightSet(0)
-    , m_textAnchorSet(0)
+    , m_familySet(false)
+    , m_sizeSet(false)
+    , m_styleSet(false)
+    , m_variantSet(false)
+    , m_weightSet(false)
+    , m_textAnchorSet(false)
 {
 }
 
@@ -276,18 +276,18 @@ QSvgStrokeStyle::QSvgStrokeStyle()
     , m_strokeDashOffset(0)
     , m_oldStrokeDashOffset(0)
     , m_style(0)
-    , m_gradientResolved(1)
-    , m_vectorEffect(0)
-    , m_oldVectorEffect(0)
-    , m_strokeSet(0)
-    , m_strokeDashArraySet(0)
-    , m_strokeDashOffsetSet(0)
-    , m_strokeLineCapSet(0)
-    , m_strokeLineJoinSet(0)
-    , m_strokeMiterLimitSet(0)
-    , m_strokeOpacitySet(0)
-    , m_strokeWidthSet(0)
-    , m_vectorEffectSet(0)
+    , m_gradientResolved(true)
+    , m_vectorEffect(false)
+    , m_oldVectorEffect(false)
+    , m_strokeSet(false)
+    , m_strokeDashArraySet(false)
+    , m_strokeDashOffsetSet(false)
+    , m_strokeLineCapSet(false)
+    , m_strokeLineJoinSet(false)
+    , m_strokeMiterLimitSet(false)
+    , m_strokeOpacitySet(false)
+    , m_strokeWidthSet(false)
+    , m_vectorEffectSet(false)
 {
 }
 
@@ -398,7 +398,7 @@ void QSvgStrokeStyle::setDashArray(const QVector<qreal> &dashes)
     } else {
         m_stroke.setDashPattern(dashes);
     }
-    m_strokeDashArraySet = 1;
+    m_strokeDashArraySet = true;
 }
 
 QSvgSolidColorStyle::QSvgSolidColorStyle(const QColor &color)
index f472562..a01bbda 100644 (file)
@@ -287,11 +287,11 @@ private:
     qreal m_oldFillOpacity;
 
     QString m_gradientId;
-    uint m_gradientResolved : 1;
+    bool m_gradientResolved;
 
-    uint m_fillRuleSet : 1;
-    uint m_fillOpacitySet : 1;
-    uint m_fillSet : 1;
+    bool m_fillRuleSet;
+    bool m_fillOpacitySet;
+    bool m_fillSet;
 };
 
 class QSvgViewportFillStyle : public QSvgStyleProperty
@@ -331,30 +331,30 @@ public:
         // Store the _pixel_ size in the font. Since QFont::setPixelSize() only takes an int, call
         // QFont::SetPointSize() instead. Set proper font size just before rendering.
         m_qfont.setPointSizeF(size);
-        m_sizeSet = 1;
+        m_sizeSet = true;
     }
 
     void setTextAnchor(Qt::Alignment anchor)
     {
         m_textAnchor = anchor;
-        m_textAnchorSet = 1;
+        m_textAnchorSet = true;
     }
 
     void setFamily(const QString &family)
     {
         m_qfont.setFamily(family);
-        m_familySet = 1;
+        m_familySet = true;
     }
 
     void setStyle(QFont::Style fontStyle) {
         m_qfont.setStyle(fontStyle);
-        m_styleSet = 1;
+        m_styleSet = true;
     }
 
     void setVariant(QFont::Capitalization fontVariant)
     {
         m_qfont.setCapitalization(fontVariant);
-        m_variantSet = 1;
+        m_variantSet = true;
     }
 
     static int SVGToQtWeight(int weight);
@@ -362,7 +362,7 @@ public:
     void setWeight(int weight)
     {
         m_weight = weight;
-        m_weightSet = 1;
+        m_weightSet = true;
     }
 
     QSvgFont * svgFont() const
@@ -390,12 +390,12 @@ private:
     Qt::Alignment m_oldTextAnchor;
     int m_oldWeight;
 
-    uint m_familySet : 1;
-    uint m_sizeSet : 1;
-    uint m_styleSet : 1;
-    uint m_variantSet : 1;
-    uint m_weightSet : 1;
-    uint m_textAnchorSet : 1;
+    bool m_familySet;
+    bool m_sizeSet;
+    bool m_styleSet;
+    bool m_variantSet;
+    bool m_weightSet;
+    bool m_textAnchorSet;
 };
 
 class QSvgStrokeStyle : public QSvgStyleProperty
@@ -410,13 +410,13 @@ public:
     {
         m_stroke.setBrush(brush);
         m_style = 0;
-        m_strokeSet = 1;
+        m_strokeSet = true;
     }
 
     void setStyle(QSvgFillStyleProperty *style)
     {
         m_style = style;
-        m_strokeSet = 1;
+        m_strokeSet = true;
     }
 
     void setDashArray(const QVector<qreal> &dashes);
@@ -424,43 +424,43 @@ public:
     void setDashArrayNone()
     {
         m_stroke.setStyle(Qt::SolidLine);
-        m_strokeDashArraySet = 1;
+        m_strokeDashArraySet = true;
     }
 
     void setDashOffset(qreal offset)
     {
         m_strokeDashOffset = offset;
-        m_strokeDashOffsetSet = 1;
+        m_strokeDashOffsetSet = true;
     }
 
     void setLineCap(Qt::PenCapStyle cap)
     {
         m_stroke.setCapStyle(cap);
-        m_strokeLineCapSet = 1;
+        m_strokeLineCapSet = true;
     }
 
     void setLineJoin(Qt::PenJoinStyle join)
     {
         m_stroke.setJoinStyle(join);
-        m_strokeLineJoinSet = 1;
+        m_strokeLineJoinSet = true;
     }
 
     void setMiterLimit(qreal limit)
     {
         m_stroke.setMiterLimit(limit);
-        m_strokeMiterLimitSet = 1;
+        m_strokeMiterLimitSet = true;
     }
 
     void setOpacity(qreal opacity)
     {
         m_strokeOpacity = opacity;
-        m_strokeOpacitySet = 1;
+        m_strokeOpacitySet = true;
     }
 
     void setWidth(qreal width)
     {
         m_stroke.setWidthF(width);
-        m_strokeWidthSet = 1;
+        m_strokeWidthSet = true;
         Q_ASSERT(!m_strokeDashArraySet); // set width before dash array.
     }
 
@@ -472,7 +472,7 @@ public:
     void setVectorEffect(bool nonScalingStroke)
     {
         m_vectorEffect = nonScalingStroke;
-        m_vectorEffectSet = 1;
+        m_vectorEffectSet = true;
     }
 
     QSvgFillStyleProperty* style() const
@@ -523,19 +523,19 @@ private:
 
     QSvgFillStyleProperty *m_style;
     QString m_gradientId;
-    uint m_gradientResolved : 1;
-    uint m_vectorEffect : 1;
-    uint m_oldVectorEffect : 1;
-
-    uint m_strokeSet : 1;
-    uint m_strokeDashArraySet : 1;
-    uint m_strokeDashOffsetSet : 1;
-    uint m_strokeLineCapSet : 1;
-    uint m_strokeLineJoinSet : 1;
-    uint m_strokeMiterLimitSet : 1;
-    uint m_strokeOpacitySet : 1;
-    uint m_strokeWidthSet : 1;
-    uint m_vectorEffectSet : 1;
+    bool m_gradientResolved;
+    bool m_vectorEffect;
+    bool m_oldVectorEffect;
+
+    bool m_strokeSet;
+    bool m_strokeDashArraySet;
+    bool m_strokeDashOffsetSet;
+    bool m_strokeLineCapSet;
+    bool m_strokeLineJoinSet;
+    bool m_strokeMiterLimitSet;
+    bool m_strokeOpacitySet;
+    bool m_strokeWidthSet;
+    bool m_vectorEffectSet;
 };
 
 class QSvgSolidColorStyle : public QSvgFillStyleProperty