Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Unified Diff: experimental/svg/model/SkSVGNode.cpp

Issue 2234153002: [SVGDom] Add more presentation attributes. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: review Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « experimental/svg/model/SkSVGDOM.cpp ('k') | experimental/svg/model/SkSVGRenderContext.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/svg/model/SkSVGNode.cpp
diff --git a/experimental/svg/model/SkSVGNode.cpp b/experimental/svg/model/SkSVGNode.cpp
index 34c6e17d619a34f9f97325ec8f01a3a5b89482e3..d60c984ceae6b6dd066a59ffaec423c229845832 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:
« no previous file with comments | « experimental/svg/model/SkSVGDOM.cpp ('k') | experimental/svg/model/SkSVGRenderContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698