diff options
author | fmalita <fmalita@chromium.org> | 2016-08-12 13:17:11 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-12 13:17:11 -0700 |
commit | ca39d716f10e75e3a2449262e67584f46d589c26 (patch) | |
tree | b34b30321c6a139b7383b1a226690acd64fbecbb /experimental/svg/model | |
parent | 09e12a6d4a75d281c47e00a64eeba893ba096f9e (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')
-rw-r--r-- | experimental/svg/model/SkSVGDOM.cpp | 4 | ||||
-rw-r--r-- | experimental/svg/model/SkSVGDOM.h | 1 | ||||
-rw-r--r-- | experimental/svg/model/SkSVGNode.cpp | 34 | ||||
-rw-r--r-- | experimental/svg/model/SkSVGNode.h | 6 |
4 files changed, 38 insertions, 7 deletions
diff --git a/experimental/svg/model/SkSVGDOM.cpp b/experimental/svg/model/SkSVGDOM.cpp index 4ae5fedd3e..c9d9e93f65 100644 --- a/experimental/svg/model/SkSVGDOM.cpp +++ b/experimental/svg/model/SkSVGDOM.cpp @@ -355,3 +355,7 @@ void SkSVGDOM::setContainerSize(const SkSize& containerSize) { // TODO: inval fContainerSize = containerSize; } + +void SkSVGDOM::setRoot(sk_sp<SkSVGNode> root) { + fRoot = std::move(root); +} diff --git a/experimental/svg/model/SkSVGDOM.h b/experimental/svg/model/SkSVGDOM.h index 468ac00a90..98f846246c 100644 --- a/experimental/svg/model/SkSVGDOM.h +++ b/experimental/svg/model/SkSVGDOM.h @@ -26,6 +26,7 @@ public: static sk_sp<SkSVGDOM> MakeFromStream(SkStream&, const SkSize& containerSize); void setContainerSize(const SkSize&); + void setRoot(sk_sp<SkSVGNode>); void render(SkCanvas*) const; 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: diff --git a/experimental/svg/model/SkSVGNode.h b/experimental/svg/model/SkSVGNode.h index 1e5c3be50f..8ffc6f9769 100644 --- a/experimental/svg/model/SkSVGNode.h +++ b/experimental/svg/model/SkSVGNode.h @@ -37,6 +37,12 @@ public: void setAttribute(SkSVGAttribute, const SkSVGValue&); + void setFill(const SkSVGPaint&); + void setFillOpacity(const SkSVGNumberType&); + void setStroke(const SkSVGPaint&); + void setStrokeOpacity(const SkSVGNumberType&); + void setStrokeWidth(const SkSVGLength&); + protected: SkSVGNode(SkSVGTag); |