aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/svg/model/SkSVGNode.cpp
diff options
context:
space:
mode:
authorGravatar fmalita <fmalita@chromium.org>2016-08-11 09:16:29 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-08-11 09:16:29 -0700
commit2d961e086bb40b371b1a667536fa089794847368 (patch)
tree89c6986af025e9d5c87791e4977838331bbd575b /experimental/svg/model/SkSVGNode.cpp
parent90b5cc31f373e831c942bfd3113b44486546846b (diff)
[SVGDom] Add more presentation attributes.
Implement proper presentation attribute inheritance, and add support for * fill-opacity * stroke-linecap * stroke-linejoin * stroke-opacity * stroke-width R=robertphillips@google.com,stephana@google.com GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2234153002 Review-Url: https://codereview.chromium.org/2234153002
Diffstat (limited to 'experimental/svg/model/SkSVGNode.cpp')
-rw-r--r--experimental/svg/model/SkSVGNode.cpp37
1 files changed, 32 insertions, 5 deletions
diff --git a/experimental/svg/model/SkSVGNode.cpp b/experimental/svg/model/SkSVGNode.cpp
index 34c6e17d61..d60c984cea 100644
--- a/experimental/svg/model/SkSVGNode.cpp
+++ b/experimental/svg/model/SkSVGNode.cpp
@@ -25,7 +25,7 @@ void SkSVGNode::render(const SkSVGRenderContext& ctx) const {
}
bool SkSVGNode::onPrepareToRender(SkSVGRenderContext* ctx) const {
- fPresentationAttributes.applyTo(ctx);
+ ctx->applyPresentationAttributes(fPresentationAttributes);
return true;
}
@@ -36,13 +36,40 @@ void SkSVGNode::setAttribute(SkSVGAttribute attr, const SkSVGValue& v) {
void SkSVGNode::onSetAttribute(SkSVGAttribute attr, const SkSVGValue& v) {
switch (attr) {
case SkSVGAttribute::kFill:
- if (const SkSVGColorValue* color = v.as<SkSVGColorValue>()) {
- fPresentationAttributes.setFill(*color);
+ if (const SkSVGPaintValue* paint = v.as<SkSVGPaintValue>()) {
+ fPresentationAttributes.fFill.set(*paint);
+ }
+ break;
+ case SkSVGAttribute::kFillOpacity:
+ if (const SkSVGNumberValue* opacity = v.as<SkSVGNumberValue>()) {
+ fPresentationAttributes.fFillOpacity.set(
+ SkSVGNumberType(SkTPin<SkScalar>((*opacity)->value(), 0, 1)));
}
break;
case SkSVGAttribute::kStroke:
- if (const SkSVGColorValue* color = v.as<SkSVGColorValue>()) {
- fPresentationAttributes.setStroke(*color);
+ if (const SkSVGPaintValue* paint = v.as<SkSVGPaintValue>()) {
+ fPresentationAttributes.fStroke.set(*paint);
+ }
+ break;
+ case SkSVGAttribute::kStrokeOpacity:
+ if (const SkSVGNumberValue* opacity = v.as<SkSVGNumberValue>()) {
+ fPresentationAttributes.fStrokeOpacity.set(
+ SkSVGNumberType(SkTPin<SkScalar>((*opacity)->value(), 0, 1)));
+ }
+ break;
+ case SkSVGAttribute::kStrokeLineCap:
+ if (const SkSVGLineCapValue* lineCap = v.as<SkSVGLineCapValue>()) {
+ fPresentationAttributes.fStrokeLineCap.set(*lineCap);
+ }
+ break;
+ case SkSVGAttribute::kStrokeLineJoin:
+ if (const SkSVGLineJoinValue* lineJoin = v.as<SkSVGLineJoinValue>()) {
+ fPresentationAttributes.fStrokeLineJoin.set(*lineJoin);
+ }
+ break;
+ case SkSVGAttribute::kStrokeWidth:
+ if (const SkSVGLengthValue* strokeWidth = v.as<SkSVGLengthValue>()) {
+ fPresentationAttributes.fStrokeWidth.set(*strokeWidth);
}
break;
default: