| @@ -560,24 +560,12 @@ private: | |||
| path.applyTransform (transform); | |||
| dp->setPath (path); | |||
| Path::Iterator iter (path); | |||
| bool containsClosedSubPath = false; | |||
| while (iter.next()) | |||
| { | |||
| if (iter.elementType == Path::Iterator::closePath) | |||
| { | |||
| containsClosedSubPath = true; | |||
| break; | |||
| } | |||
| } | |||
| dp->setFill (getPathFillType (path, | |||
| getStyleAttribute (xml, "fill"), | |||
| getStyleAttribute (xml, "fill-opacity"), | |||
| getStyleAttribute (xml, "opacity"), | |||
| containsClosedSubPath ? Colours::black | |||
| : Colours::transparentBlack)); | |||
| pathContainsClosedSubPath (path) ? Colours::black | |||
| : Colours::transparentBlack)); | |||
| const String strokeType (getStyleAttribute (xml, "stroke")); | |||
| @@ -594,6 +582,15 @@ private: | |||
| return dp; | |||
| } | |||
| static bool pathContainsClosedSubPath (const Path& path) noexcept | |||
| { | |||
| for (Path::Iterator iter (path); iter.next();) | |||
| if (iter.elementType == Path::Iterator::closePath) | |||
| return true; | |||
| return false; | |||
| } | |||
| struct SetGradientStopsOp | |||
| { | |||
| const SVGState* state; | |||
| @@ -796,44 +793,41 @@ private: | |||
| return parseColour (fill, i, defaultColour).withMultipliedAlpha (opacity); | |||
| } | |||
| PathStrokeType getStrokeFor (const XmlPath& xml) const | |||
| static PathStrokeType::JointStyle getJointStyle (const String& join) noexcept | |||
| { | |||
| const String strokeWidth (getStyleAttribute (xml, "stroke-width")); | |||
| const String cap (getStyleAttribute (xml, "stroke-linecap")); | |||
| const String join (getStyleAttribute (xml, "stroke-linejoin")); | |||
| //const String mitreLimit (getStyleAttribute (xml, "stroke-miterlimit")); | |||
| //const String dashArray (getStyleAttribute (xml, "stroke-dasharray")); | |||
| //const String dashOffset (getStyleAttribute (xml, "stroke-dashoffset")); | |||
| if (join.equalsIgnoreCase ("round")) return PathStrokeType::curved; | |||
| if (join.equalsIgnoreCase ("bevel")) return PathStrokeType::beveled; | |||
| PathStrokeType::JointStyle joinStyle = PathStrokeType::mitered; | |||
| PathStrokeType::EndCapStyle capStyle = PathStrokeType::butt; | |||
| return PathStrokeType::mitered; | |||
| } | |||
| if (join.equalsIgnoreCase ("round")) | |||
| joinStyle = PathStrokeType::curved; | |||
| else if (join.equalsIgnoreCase ("bevel")) | |||
| joinStyle = PathStrokeType::beveled; | |||
| static PathStrokeType::EndCapStyle getEndCapStyle (const String& cap) noexcept | |||
| { | |||
| if (cap.equalsIgnoreCase ("round")) return PathStrokeType::rounded; | |||
| if (cap.equalsIgnoreCase ("square")) return PathStrokeType::square; | |||
| if (cap.equalsIgnoreCase ("round")) | |||
| capStyle = PathStrokeType::rounded; | |||
| else if (cap.equalsIgnoreCase ("square")) | |||
| capStyle = PathStrokeType::square; | |||
| return PathStrokeType::butt; | |||
| } | |||
| float ox = 0.0f, oy = 0.0f; | |||
| float x = getCoordLength (strokeWidth, viewBoxW), y = 0.0f; | |||
| transform.transformPoints (ox, oy, x, y); | |||
| float getStrokeWidth (const String& strokeWidth) const noexcept | |||
| { | |||
| return transform.getScaleFactor() * getCoordLength (strokeWidth, viewBoxW); | |||
| } | |||
| return PathStrokeType (strokeWidth.isNotEmpty() ? juce_hypot (x - ox, y - oy) : 1.0f, | |||
| joinStyle, capStyle); | |||
| PathStrokeType getStrokeFor (const XmlPath& xml) const | |||
| { | |||
| return PathStrokeType (getStrokeWidth (getStyleAttribute (xml, "stroke-width", "1")), | |||
| getJointStyle (getStyleAttribute (xml, "stroke-linejoin")), | |||
| getEndCapStyle (getStyleAttribute (xml, "stroke-linecap"))); | |||
| } | |||
| //============================================================================== | |||
| Drawable* parseText (const XmlPath& xml) | |||
| { | |||
| Array <float> xCoords, yCoords, dxCoords, dyCoords; | |||
| Array<float> xCoords, yCoords, dxCoords, dyCoords; | |||
| getCoordList (xCoords, getInheritedAttribute (xml, "x"), true, true); | |||
| getCoordList (yCoords, getInheritedAttribute (xml, "y"), true, false); | |||
| getCoordList (xCoords, getInheritedAttribute (xml, "x"), true, true); | |||
| getCoordList (yCoords, getInheritedAttribute (xml, "y"), true, false); | |||
| getCoordList (dxCoords, getInheritedAttribute (xml, "dx"), true, true); | |||
| getCoordList (dyCoords, getInheritedAttribute (xml, "dy"), true, false); | |||
| @@ -898,7 +892,7 @@ private: | |||
| return false; | |||
| } | |||
| float getCoordLength (const String& s, const float sizeForProportions) const | |||
| float getCoordLength (const String& s, const float sizeForProportions) const noexcept | |||
| { | |||
| float n = s.getFloatValue(); | |||
| const int len = s.length(); | |||
| @@ -920,13 +914,12 @@ private: | |||
| return n; | |||
| } | |||
| float getCoordLength (const XmlPath& xml, const char* attName, const float sizeForProportions) const | |||
| float getCoordLength (const XmlPath& xml, const char* attName, const float sizeForProportions) const noexcept | |||
| { | |||
| return getCoordLength (xml->getStringAttribute (attName), sizeForProportions); | |||
| } | |||
| void getCoordList (Array <float>& coords, const String& list, | |||
| const bool allowUnits, const bool isX) const | |||
| void getCoordList (Array<float>& coords, const String& list, bool allowUnits, const bool isX) const | |||
| { | |||
| String::CharPointerType text (list.getCharPointer()); | |||
| float value; | |||
| @@ -960,7 +953,7 @@ private: | |||
| return source; | |||
| } | |||
| String getStyleAttribute (const XmlPath& xml, const String& attributeName, | |||
| String getStyleAttribute (const XmlPath& xml, StringRef attributeName, | |||
| const String& defaultValue = String()) const | |||
| { | |||
| if (xml->hasAttribute (attributeName)) | |||
| @@ -1000,7 +993,7 @@ private: | |||
| return defaultValue; | |||
| } | |||
| String getInheritedAttribute (const XmlPath& xml, const String& attributeName) const | |||
| String getInheritedAttribute (const XmlPath& xml, StringRef attributeName) const | |||
| { | |||
| if (xml->hasAttribute (attributeName)) | |||
| return xml->getStringAttribute (attributeName); | |||
| @@ -1017,7 +1010,7 @@ private: | |||
| return CharacterFunctions::isLetter (c) || c == '-'; | |||
| } | |||
| static String getAttributeFromStyleList (const String& list, const String& attributeName, const String& defaultValue) | |||
| static String getAttributeFromStyleList (const String& list, StringRef attributeName, const String& defaultValue) | |||
| { | |||
| int i = 0; | |||
| @@ -1221,7 +1214,7 @@ private: | |||
| const bool largeArc, const bool sweep, | |||
| double& rx, double& ry, | |||
| double& centreX, double& centreY, | |||
| double& startAngle, double& deltaAngle) | |||
| double& startAngle, double& deltaAngle) noexcept | |||
| { | |||
| const double midX = (x1 - x2) * 0.5; | |||
| const double midY = (y1 - y2) * 0.5; | |||