File indexing completed on 2024-04-28 15:24:30
0001 /* 0002 Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 0003 2004, 2005, 2006 Rob Buis <buis@kde.org> 0004 0005 This file is part of the KDE project 0006 0007 This library is free software; you can redistribute it and/or 0008 modify it under the terms of the GNU Library General Public 0009 License as published by the Free Software Foundation; either 0010 version 2 of the License, or (at your option) any later version. 0011 0012 This library is distributed in the hope that it will be useful, 0013 but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 Library General Public License for more details. 0016 0017 You should have received a copy of the GNU Library General Public License 0018 along with this library; see the file COPYING.LIB. If not, write to 0019 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0020 Boston, MA 02110-1301, USA. 0021 */ 0022 0023 #if ENABLE(SVG) && ENABLE(SVG_FILTERS) 0024 #include "SVGFECompositeElement.h" 0025 0026 #include "SVGNames.h" 0027 #include "SVGResourceFilter.h" 0028 0029 namespace WebCore 0030 { 0031 0032 SVGFECompositeElement::SVGFECompositeElement(const QualifiedName &tagName, Document *doc) 0033 : SVGFilterPrimitiveStandardAttributes(tagName, doc) 0034 , m__operator(SVG_FECOMPOSITE_OPERATOR_OVER) 0035 , m_k1(0.0f) 0036 , m_k2(0.0f) 0037 , m_k3(0.0f) 0038 , m_k4(0.0f) 0039 , m_filterEffect(0) 0040 { 0041 } 0042 0043 SVGFECompositeElement::~SVGFECompositeElement() 0044 { 0045 delete m_filterEffect; 0046 } 0047 0048 ANIMATED_PROPERTY_DEFINITIONS(SVGFECompositeElement, String, String, string, In1, in1, SVGNames::inAttr, m_in1) 0049 ANIMATED_PROPERTY_DEFINITIONS(SVGFECompositeElement, String, String, string, In2, in2, SVGNames::in2Attr, m_in2) 0050 ANIMATED_PROPERTY_DEFINITIONS(SVGFECompositeElement, int, Enumeration, enumeration, _operator, _operator, SVGNames::operatorAttr, m__operator) 0051 ANIMATED_PROPERTY_DEFINITIONS(SVGFECompositeElement, float, Number, number, K1, k1, SVGNames::k1Attr, m_k1) 0052 ANIMATED_PROPERTY_DEFINITIONS(SVGFECompositeElement, float, Number, number, K2, k2, SVGNames::k2Attr, m_k2) 0053 ANIMATED_PROPERTY_DEFINITIONS(SVGFECompositeElement, float, Number, number, K3, k3, SVGNames::k3Attr, m_k3) 0054 ANIMATED_PROPERTY_DEFINITIONS(SVGFECompositeElement, float, Number, number, K4, k4, SVGNames::k4Attr, m_k4) 0055 0056 void SVGFECompositeElement::parseMappedAttribute(MappedAttribute *attr) 0057 { 0058 const String &value = attr->value(); 0059 if (attr->name() == SVGNames::operatorAttr) { 0060 if (value == "over") { 0061 set_operatorBaseValue(SVG_FECOMPOSITE_OPERATOR_OVER); 0062 } else if (value == "in") { 0063 set_operatorBaseValue(SVG_FECOMPOSITE_OPERATOR_IN); 0064 } else if (value == "out") { 0065 set_operatorBaseValue(SVG_FECOMPOSITE_OPERATOR_OUT); 0066 } else if (value == "atop") { 0067 set_operatorBaseValue(SVG_FECOMPOSITE_OPERATOR_ATOP); 0068 } else if (value == "xor") { 0069 set_operatorBaseValue(SVG_FECOMPOSITE_OPERATOR_XOR); 0070 } else if (value == "arithmetic") { 0071 set_operatorBaseValue(SVG_FECOMPOSITE_OPERATOR_ARITHMETIC); 0072 } 0073 } else if (attr->name() == SVGNames::inAttr) { 0074 setIn1BaseValue(value); 0075 } else if (attr->name() == SVGNames::in2Attr) { 0076 setIn2BaseValue(value); 0077 } else if (attr->name() == SVGNames::k1Attr) { 0078 setK1BaseValue(value.toFloat()); 0079 } else if (attr->name() == SVGNames::k2Attr) { 0080 setK2BaseValue(value.toFloat()); 0081 } else if (attr->name() == SVGNames::k3Attr) { 0082 setK3BaseValue(value.toFloat()); 0083 } else if (attr->name() == SVGNames::k4Attr) { 0084 setK4BaseValue(value.toFloat()); 0085 } else { 0086 SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr); 0087 } 0088 } 0089 0090 SVGFEComposite *SVGFECompositeElement::filterEffect(SVGResourceFilter *filter) const 0091 { 0092 if (!m_filterEffect) { 0093 m_filterEffect = new SVGFEComposite(filter); 0094 } 0095 0096 m_filterEffect->setOperation((SVGCompositeOperationType) _operator()); 0097 m_filterEffect->setIn(in1()); 0098 m_filterEffect->setIn2(in2()); 0099 m_filterEffect->setK1(k1()); 0100 m_filterEffect->setK2(k2()); 0101 m_filterEffect->setK3(k3()); 0102 m_filterEffect->setK4(k4()); 0103 0104 setStandardAttributes(m_filterEffect); 0105 return m_filterEffect; 0106 } 0107 0108 } 0109 0110 #endif // ENABLE(SVG) 0111