aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/svg/model/SkSVGNode.cpp
diff options
context:
space:
mode:
authorGravatar fmalita <fmalita@chromium.org>2016-08-12 13:17:11 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-08-12 13:17:11 -0700
commitca39d716f10e75e3a2449262e67584f46d589c26 (patch)
treeb34b30321c6a139b7383b1a226690acd64fbecbb /experimental/svg/model/SkSVGNode.cpp
parent09e12a6d4a75d281c47e00a64eeba893ba096f9e (diff)
[SVGDom] SVGPong sample app
Shows off SVG dom-based animations. R=robertphillips@google.com,stephana@google.com GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2243853003 Review-Url: https://codereview.chromium.org/2243853003
Diffstat (limited to 'experimental/svg/model/SkSVGNode.cpp')
-rw-r--r--experimental/svg/model/SkSVGNode.cpp34
1 files changed, 27 insertions, 7 deletions
diff --git a/experimental/svg/model/SkSVGNode.cpp b/experimental/svg/model/SkSVGNode.cpp
index d60c984cea..a039b59ff1 100644
--- a/experimental/svg/model/SkSVGNode.cpp
+++ b/experimental/svg/model/SkSVGNode.cpp
@@ -33,28 +33,48 @@ void SkSVGNode::setAttribute(SkSVGAttribute attr, const SkSVGValue& v) {
this->onSetAttribute(attr, v);
}
+void SkSVGNode::setFill(const SkSVGPaint& svgPaint) {
+ fPresentationAttributes.fFill.set(svgPaint);
+}
+
+void SkSVGNode::setFillOpacity(const SkSVGNumberType& opacity) {
+ fPresentationAttributes.fFillOpacity.set(
+ SkSVGNumberType(SkTPin<SkScalar>(opacity.value(), 0, 1)));
+}
+
+void SkSVGNode::setStroke(const SkSVGPaint& svgPaint) {
+ fPresentationAttributes.fStroke.set(svgPaint);
+}
+
+void SkSVGNode::setStrokeOpacity(const SkSVGNumberType& opacity) {
+ fPresentationAttributes.fStrokeOpacity.set(
+ SkSVGNumberType(SkTPin<SkScalar>(opacity.value(), 0, 1)));
+}
+
+void SkSVGNode::setStrokeWidth(const SkSVGLength& strokeWidth) {
+ fPresentationAttributes.fStrokeWidth.set(strokeWidth);
+}
+
void SkSVGNode::onSetAttribute(SkSVGAttribute attr, const SkSVGValue& v) {
switch (attr) {
case SkSVGAttribute::kFill:
if (const SkSVGPaintValue* paint = v.as<SkSVGPaintValue>()) {
- fPresentationAttributes.fFill.set(*paint);
+ this->setFill(*paint);
}
break;
case SkSVGAttribute::kFillOpacity:
if (const SkSVGNumberValue* opacity = v.as<SkSVGNumberValue>()) {
- fPresentationAttributes.fFillOpacity.set(
- SkSVGNumberType(SkTPin<SkScalar>((*opacity)->value(), 0, 1)));
+ this->setFillOpacity(*opacity);
}
break;
case SkSVGAttribute::kStroke:
if (const SkSVGPaintValue* paint = v.as<SkSVGPaintValue>()) {
- fPresentationAttributes.fStroke.set(*paint);
+ this->setStroke(*paint);
}
break;
case SkSVGAttribute::kStrokeOpacity:
if (const SkSVGNumberValue* opacity = v.as<SkSVGNumberValue>()) {
- fPresentationAttributes.fStrokeOpacity.set(
- SkSVGNumberType(SkTPin<SkScalar>((*opacity)->value(), 0, 1)));
+ this->setStrokeOpacity(*opacity);
}
break;
case SkSVGAttribute::kStrokeLineCap:
@@ -69,7 +89,7 @@ void SkSVGNode::onSetAttribute(SkSVGAttribute attr, const SkSVGValue& v) {
break;
case SkSVGAttribute::kStrokeWidth:
if (const SkSVGLengthValue* strokeWidth = v.as<SkSVGLengthValue>()) {
- fPresentationAttributes.fStrokeWidth.set(*strokeWidth);
+ this->setStrokeWidth(*strokeWidth);
}
break;
default: