[svg] Convert stop-color and stop-opacity to presentation attrs
These are somewhat the first presentation attributes of their kind,
in that they are non-inherited but also not applied via canvas layers.
Implementation-wise the main difference is that these attributes are
not propagated through the fInherited field of the render context's
presentation attribute list.
Change-Id: I0909507b0ecbd21732b3f80c46a343f5a0a9bf7a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/340661
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Tyler Denniston <tdenniston@google.com>
diff --git a/modules/svg/src/SkSVGNode.cpp b/modules/svg/src/SkSVGNode.cpp
index a8f39ad..acf8f8f 100644
--- a/modules/svg/src/SkSVGNode.cpp
+++ b/modules/svg/src/SkSVGNode.cpp
@@ -14,7 +14,11 @@
#include "modules/svg/include/SkSVGValue.h"
#include "src/core/SkTLazy.h"
-SkSVGNode::SkSVGNode(SkSVGTag t) : fTag(t) { }
+SkSVGNode::SkSVGNode(SkSVGTag t) : fTag(t) {
+ // Uninherited presentation attributes need a non-null default value.
+ fPresentationAttributes.fStopColor.set(SkSVGColor(SK_ColorBLACK));
+ fPresentationAttributes.fStopOpacity.set(SkSVGNumberType(1.0f));
+}
SkSVGNode::~SkSVGNode() { }
@@ -94,6 +98,8 @@
|| PARSE_AND_SET("font-style" , FontStyle)
|| PARSE_AND_SET("font-weight" , FontWeight)
|| PARSE_AND_SET("opacity" , Opacity)
+ || PARSE_AND_SET("stop-color" , StopColor)
+ || PARSE_AND_SET("stop-opacity" , StopOpacity)
|| PARSE_AND_SET("stroke" , Stroke)
|| PARSE_AND_SET("stroke-dasharray" , StrokeDashArray)
|| PARSE_AND_SET("stroke-dashoffset", StrokeDashOffset)