aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/svg
diff options
context:
space:
mode:
authorGravatar Florin Malita <fmalita@chromium.org>2017-10-09 12:57:41 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-10-10 16:20:43 +0000
commit4de426b2422bec260686b6c4e3c4834eeffe864f (patch)
treede13e5cb22845f988296f28dbf4e33bd1e33e160 /experimental/svg
parenta108c92ae5868ca99759a872edddb377f31ad1be (diff)
[SVGDom] stroke-miterlimit support
https://www.w3.org/TR/SVG/painting.html#StrokeMiterlimitProperty Change-Id: I5e488e95afe17c4b753e8177ea5783d4820e3d2c Reviewed-on: https://skia-review.googlesource.com/57221 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'experimental/svg')
-rw-r--r--experimental/svg/model/SkSVGAttribute.cpp1
-rw-r--r--experimental/svg/model/SkSVGAttribute.h2
-rw-r--r--experimental/svg/model/SkSVGDOM.cpp1
-rw-r--r--experimental/svg/model/SkSVGNode.cpp5
-rw-r--r--experimental/svg/model/SkSVGRenderContext.cpp9
5 files changed, 18 insertions, 0 deletions
diff --git a/experimental/svg/model/SkSVGAttribute.cpp b/experimental/svg/model/SkSVGAttribute.cpp
index 4935d6afcf..6d318ca2f2 100644
--- a/experimental/svg/model/SkSVGAttribute.cpp
+++ b/experimental/svg/model/SkSVGAttribute.cpp
@@ -17,6 +17,7 @@ SkSVGPresentationAttributes SkSVGPresentationAttributes::MakeInitial() {
result.fStroke.set(SkSVGPaint(SkSVGPaint::Type::kNone));
result.fStrokeLineCap.set(SkSVGLineCap(SkSVGLineCap::Type::kButt));
result.fStrokeLineJoin.set(SkSVGLineJoin(SkSVGLineJoin::Type::kMiter));
+ result.fStrokeMiterLimit.set(SkSVGNumberType(4));
result.fStrokeOpacity.set(SkSVGNumberType(1));
result.fStrokeWidth.set(SkSVGLength(1));
diff --git a/experimental/svg/model/SkSVGAttribute.h b/experimental/svg/model/SkSVGAttribute.h
index 084fcc0290..6c88326420 100644
--- a/experimental/svg/model/SkSVGAttribute.h
+++ b/experimental/svg/model/SkSVGAttribute.h
@@ -39,6 +39,7 @@ enum class SkSVGAttribute {
kStrokeOpacity,
kStrokeLineCap,
kStrokeLineJoin,
+ kStrokeMiterLimit,
kStrokeWidth,
kTransform,
kViewBox,
@@ -65,6 +66,7 @@ struct SkSVGPresentationAttributes {
SkTLazy<SkSVGPaint> fStroke;
SkTLazy<SkSVGLineCap> fStrokeLineCap;
SkTLazy<SkSVGLineJoin> fStrokeLineJoin;
+ SkTLazy<SkSVGNumberType> fStrokeMiterLimit;
SkTLazy<SkSVGNumberType> fStrokeOpacity;
SkTLazy<SkSVGLength> fStrokeWidth;
diff --git a/experimental/svg/model/SkSVGDOM.cpp b/experimental/svg/model/SkSVGDOM.cpp
index c2f8fc5116..70db9330a4 100644
--- a/experimental/svg/model/SkSVGDOM.cpp
+++ b/experimental/svg/model/SkSVGDOM.cpp
@@ -302,6 +302,7 @@ SortedDictionaryEntry<AttrParseInfo> gAttributeParseInfo[] = {
{ "stroke" , { SkSVGAttribute::kStroke , SetPaintAttribute }},
{ "stroke-linecap" , { SkSVGAttribute::kStrokeLineCap , SetLineCapAttribute }},
{ "stroke-linejoin" , { SkSVGAttribute::kStrokeLineJoin , SetLineJoinAttribute }},
+ { "stroke-miterlimit", { SkSVGAttribute::kStrokeMiterLimit , SetNumberAttribute }},
{ "stroke-opacity" , { SkSVGAttribute::kStrokeOpacity , SetNumberAttribute }},
{ "stroke-width" , { SkSVGAttribute::kStrokeWidth , SetLengthAttribute }},
{ "style" , { SkSVGAttribute::kUnknown , SetStyleAttributes }},
diff --git a/experimental/svg/model/SkSVGNode.cpp b/experimental/svg/model/SkSVGNode.cpp
index 0f3743ffd2..46d6423af2 100644
--- a/experimental/svg/model/SkSVGNode.cpp
+++ b/experimental/svg/model/SkSVGNode.cpp
@@ -139,6 +139,11 @@ void SkSVGNode::onSetAttribute(SkSVGAttribute attr, const SkSVGValue& v) {
fPresentationAttributes.fStrokeLineJoin.set(*lineJoin);
}
break;
+ case SkSVGAttribute::kStrokeMiterLimit:
+ if (const SkSVGNumberValue* miterLimit = v.as<SkSVGNumberValue>()) {
+ fPresentationAttributes.fStrokeMiterLimit.set(*miterLimit);
+ }
+ break;
case SkSVGAttribute::kStrokeWidth:
if (const SkSVGLengthValue* strokeWidth = v.as<SkSVGLengthValue>()) {
this->setStrokeWidth(*strokeWidth);
diff --git a/experimental/svg/model/SkSVGRenderContext.cpp b/experimental/svg/model/SkSVGRenderContext.cpp
index 9de605a034..f071d9696f 100644
--- a/experimental/svg/model/SkSVGRenderContext.cpp
+++ b/experimental/svg/model/SkSVGRenderContext.cpp
@@ -174,6 +174,13 @@ void commitToPaint<SkSVGAttribute::kStrokeLineJoin>(const SkSVGPresentationAttri
}
template <>
+void commitToPaint<SkSVGAttribute::kStrokeMiterLimit>(const SkSVGPresentationAttributes& attrs,
+ const SkSVGRenderContext&,
+ SkSVGPresentationContext* pctx) {
+ pctx->fStrokePaint.setStrokeMiter(*attrs.fStrokeMiterLimit.get());
+}
+
+template <>
void commitToPaint<SkSVGAttribute::kStrokeOpacity>(const SkSVGPresentationAttributes& attrs,
const SkSVGRenderContext&,
SkSVGPresentationContext* pctx) {
@@ -218,6 +225,7 @@ SkSVGPresentationContext::SkSVGPresentationContext()
commitToPaint<SkSVGAttribute::kStroke>(fInherited, dummy, this);
commitToPaint<SkSVGAttribute::kStrokeLineCap>(fInherited, dummy, this);
commitToPaint<SkSVGAttribute::kStrokeLineJoin>(fInherited, dummy, this);
+ commitToPaint<SkSVGAttribute::kStrokeMiterLimit>(fInherited, dummy, this);
commitToPaint<SkSVGAttribute::kStrokeOpacity>(fInherited, dummy, this);
commitToPaint<SkSVGAttribute::kStrokeWidth>(fInherited, dummy, this);
}
@@ -270,6 +278,7 @@ void SkSVGRenderContext::applyPresentationAttributes(const SkSVGPresentationAttr
ApplyLazyInheritedAttribute(Stroke);
ApplyLazyInheritedAttribute(StrokeLineCap);
ApplyLazyInheritedAttribute(StrokeLineJoin);
+ ApplyLazyInheritedAttribute(StrokeMiterLimit);
ApplyLazyInheritedAttribute(StrokeOpacity);
ApplyLazyInheritedAttribute(StrokeWidth);