|
1 /* |
|
2 Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> |
|
3 2004, 2005, 2006 Rob Buis <buis@kde.org> |
|
4 |
|
5 This library is free software; you can redistribute it and/or |
|
6 modify it under the terms of the GNU Library General Public |
|
7 License as published by the Free Software Foundation; either |
|
8 version 2 of the License, or (at your option) any later version. |
|
9 |
|
10 This library is distributed in the hope that it will be useful, |
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 Library General Public License for more details. |
|
14 |
|
15 You should have received a copy of the GNU Library General Public License |
|
16 along with this library; see the file COPYING.LIB. If not, write to |
|
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|
18 Boston, MA 02110-1301, USA. |
|
19 */ |
|
20 |
|
21 #include "config.h" |
|
22 |
|
23 #if ENABLE(SVG) && ENABLE(FILTERS) |
|
24 #include "SVGFEBlendElement.h" |
|
25 |
|
26 #include "Attribute.h" |
|
27 |
|
28 namespace WebCore { |
|
29 |
|
30 SVGFEBlendElement::SVGFEBlendElement(const QualifiedName& tagName, Document* doc) |
|
31 : SVGFilterPrimitiveStandardAttributes(tagName, doc) |
|
32 , m_mode(FEBLEND_MODE_NORMAL) |
|
33 { |
|
34 } |
|
35 |
|
36 SVGFEBlendElement::~SVGFEBlendElement() |
|
37 { |
|
38 } |
|
39 |
|
40 void SVGFEBlendElement::parseMappedAttribute(Attribute* attr) |
|
41 { |
|
42 const String& value = attr->value(); |
|
43 if (attr->name() == SVGNames::modeAttr) { |
|
44 if (value == "normal") |
|
45 setModeBaseValue(FEBLEND_MODE_NORMAL); |
|
46 else if (value == "multiply") |
|
47 setModeBaseValue(FEBLEND_MODE_MULTIPLY); |
|
48 else if (value == "screen") |
|
49 setModeBaseValue(FEBLEND_MODE_SCREEN); |
|
50 else if (value == "darken") |
|
51 setModeBaseValue(FEBLEND_MODE_DARKEN); |
|
52 else if (value == "lighten") |
|
53 setModeBaseValue(FEBLEND_MODE_LIGHTEN); |
|
54 } else if (attr->name() == SVGNames::inAttr) |
|
55 setIn1BaseValue(value); |
|
56 else if (attr->name() == SVGNames::in2Attr) |
|
57 setIn2BaseValue(value); |
|
58 else |
|
59 SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr); |
|
60 } |
|
61 |
|
62 void SVGFEBlendElement::synchronizeProperty(const QualifiedName& attrName) |
|
63 { |
|
64 SVGFilterPrimitiveStandardAttributes::synchronizeProperty(attrName); |
|
65 |
|
66 if (attrName == anyQName()) { |
|
67 synchronizeMode(); |
|
68 synchronizeIn1(); |
|
69 synchronizeIn2(); |
|
70 return; |
|
71 } |
|
72 |
|
73 if (attrName == SVGNames::modeAttr) |
|
74 synchronizeMode(); |
|
75 else if (attrName == SVGNames::inAttr) |
|
76 synchronizeIn1(); |
|
77 else if (attrName == SVGNames::in2Attr) |
|
78 synchronizeIn2(); |
|
79 } |
|
80 |
|
81 PassRefPtr<FilterEffect> SVGFEBlendElement::build(SVGFilterBuilder* filterBuilder) |
|
82 { |
|
83 FilterEffect* input1 = filterBuilder->getEffectById(in1()); |
|
84 FilterEffect* input2 = filterBuilder->getEffectById(in2()); |
|
85 |
|
86 if (!input1 || !input2) |
|
87 return 0; |
|
88 |
|
89 return FEBlend::create(input1, input2, static_cast<BlendModeType>(mode())); |
|
90 } |
|
91 |
|
92 } |
|
93 |
|
94 #endif // ENABLE(SVG) |
|
95 |
|
96 // vim:ts=4:noet |