OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkMatrix.h" | 9 #include "SkMatrix.h" |
10 #include "SkSVGNode.h" | 10 #include "SkSVGNode.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 | 35 |
36 void SkSVGNode::setFill(const SkSVGPaint& svgPaint) { | 36 void SkSVGNode::setFill(const SkSVGPaint& svgPaint) { |
37 fPresentationAttributes.fFill.set(svgPaint); | 37 fPresentationAttributes.fFill.set(svgPaint); |
38 } | 38 } |
39 | 39 |
40 void SkSVGNode::setFillOpacity(const SkSVGNumberType& opacity) { | 40 void SkSVGNode::setFillOpacity(const SkSVGNumberType& opacity) { |
41 fPresentationAttributes.fFillOpacity.set( | 41 fPresentationAttributes.fFillOpacity.set( |
42 SkSVGNumberType(SkTPin<SkScalar>(opacity.value(), 0, 1))); | 42 SkSVGNumberType(SkTPin<SkScalar>(opacity.value(), 0, 1))); |
43 } | 43 } |
44 | 44 |
| 45 void SkSVGNode::setOpacity(const SkSVGNumberType& opacity) { |
| 46 fPresentationAttributes.fOpacity.set( |
| 47 SkSVGNumberType(SkTPin<SkScalar>(opacity.value(), 0, 1))); |
| 48 } |
| 49 |
45 void SkSVGNode::setStroke(const SkSVGPaint& svgPaint) { | 50 void SkSVGNode::setStroke(const SkSVGPaint& svgPaint) { |
46 fPresentationAttributes.fStroke.set(svgPaint); | 51 fPresentationAttributes.fStroke.set(svgPaint); |
47 } | 52 } |
48 | 53 |
49 void SkSVGNode::setStrokeOpacity(const SkSVGNumberType& opacity) { | 54 void SkSVGNode::setStrokeOpacity(const SkSVGNumberType& opacity) { |
50 fPresentationAttributes.fStrokeOpacity.set( | 55 fPresentationAttributes.fStrokeOpacity.set( |
51 SkSVGNumberType(SkTPin<SkScalar>(opacity.value(), 0, 1))); | 56 SkSVGNumberType(SkTPin<SkScalar>(opacity.value(), 0, 1))); |
52 } | 57 } |
53 | 58 |
54 void SkSVGNode::setStrokeWidth(const SkSVGLength& strokeWidth) { | 59 void SkSVGNode::setStrokeWidth(const SkSVGLength& strokeWidth) { |
55 fPresentationAttributes.fStrokeWidth.set(strokeWidth); | 60 fPresentationAttributes.fStrokeWidth.set(strokeWidth); |
56 } | 61 } |
57 | 62 |
58 void SkSVGNode::onSetAttribute(SkSVGAttribute attr, const SkSVGValue& v) { | 63 void SkSVGNode::onSetAttribute(SkSVGAttribute attr, const SkSVGValue& v) { |
59 switch (attr) { | 64 switch (attr) { |
60 case SkSVGAttribute::kFill: | 65 case SkSVGAttribute::kFill: |
61 if (const SkSVGPaintValue* paint = v.as<SkSVGPaintValue>()) { | 66 if (const SkSVGPaintValue* paint = v.as<SkSVGPaintValue>()) { |
62 this->setFill(*paint); | 67 this->setFill(*paint); |
63 } | 68 } |
64 break; | 69 break; |
65 case SkSVGAttribute::kFillOpacity: | 70 case SkSVGAttribute::kFillOpacity: |
66 if (const SkSVGNumberValue* opacity = v.as<SkSVGNumberValue>()) { | 71 if (const SkSVGNumberValue* opacity = v.as<SkSVGNumberValue>()) { |
67 this->setFillOpacity(*opacity); | 72 this->setFillOpacity(*opacity); |
68 } | 73 } |
69 break; | 74 break; |
| 75 case SkSVGAttribute::kOpacity: |
| 76 if (const SkSVGNumberValue* opacity = v.as<SkSVGNumberValue>()) { |
| 77 this->setOpacity(*opacity); |
| 78 } |
| 79 break; |
70 case SkSVGAttribute::kStroke: | 80 case SkSVGAttribute::kStroke: |
71 if (const SkSVGPaintValue* paint = v.as<SkSVGPaintValue>()) { | 81 if (const SkSVGPaintValue* paint = v.as<SkSVGPaintValue>()) { |
72 this->setStroke(*paint); | 82 this->setStroke(*paint); |
73 } | 83 } |
74 break; | 84 break; |
75 case SkSVGAttribute::kStrokeOpacity: | 85 case SkSVGAttribute::kStrokeOpacity: |
76 if (const SkSVGNumberValue* opacity = v.as<SkSVGNumberValue>()) { | 86 if (const SkSVGNumberValue* opacity = v.as<SkSVGNumberValue>()) { |
77 this->setStrokeOpacity(*opacity); | 87 this->setStrokeOpacity(*opacity); |
78 } | 88 } |
79 break; | 89 break; |
(...skipping 10 matching lines...) Expand all Loading... |
90 case SkSVGAttribute::kStrokeWidth: | 100 case SkSVGAttribute::kStrokeWidth: |
91 if (const SkSVGLengthValue* strokeWidth = v.as<SkSVGLengthValue>()) { | 101 if (const SkSVGLengthValue* strokeWidth = v.as<SkSVGLengthValue>()) { |
92 this->setStrokeWidth(*strokeWidth); | 102 this->setStrokeWidth(*strokeWidth); |
93 } | 103 } |
94 break; | 104 break; |
95 default: | 105 default: |
96 SkDebugf("attribute ID <%d> ignored for node <%d>\n", attr, fTag); | 106 SkDebugf("attribute ID <%d> ignored for node <%d>\n", attr, fTag); |
97 break; | 107 break; |
98 } | 108 } |
99 } | 109 } |
OLD | NEW |