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 "SVGFEBlendElement.h" 0025 0026 #include "SVGResourceFilter.h" 0027 0028 namespace WebCore 0029 { 0030 0031 SVGFEBlendElement::SVGFEBlendElement(const QualifiedName &tagName, Document *doc) 0032 : SVGFilterPrimitiveStandardAttributes(tagName, doc) 0033 , m_mode(SVG_FEBLEND_MODE_NORMAL) 0034 , m_filterEffect(0) 0035 { 0036 } 0037 0038 SVGFEBlendElement::~SVGFEBlendElement() 0039 { 0040 delete m_filterEffect; 0041 } 0042 0043 ANIMATED_PROPERTY_DEFINITIONS(SVGFEBlendElement, String, String, string, In1, in1, SVGNames::inAttr, m_in1) 0044 ANIMATED_PROPERTY_DEFINITIONS(SVGFEBlendElement, String, String, string, In2, in2, SVGNames::in2Attr, m_in2) 0045 ANIMATED_PROPERTY_DEFINITIONS(SVGFEBlendElement, int, Enumeration, enumeration, Mode, mode, SVGNames::modeAttr, m_mode) 0046 0047 void SVGFEBlendElement::parseMappedAttribute(MappedAttribute *attr) 0048 { 0049 const String &value = attr->value(); 0050 if (attr->name() == SVGNames::modeAttr) { 0051 if (value == "normal") { 0052 setModeBaseValue(SVG_FEBLEND_MODE_NORMAL); 0053 } else if (value == "multiply") { 0054 setModeBaseValue(SVG_FEBLEND_MODE_MULTIPLY); 0055 } else if (value == "screen") { 0056 setModeBaseValue(SVG_FEBLEND_MODE_SCREEN); 0057 } else if (value == "darken") { 0058 setModeBaseValue(SVG_FEBLEND_MODE_DARKEN); 0059 } else if (value == "lighten") { 0060 setModeBaseValue(SVG_FEBLEND_MODE_LIGHTEN); 0061 } 0062 } else if (attr->name() == SVGNames::inAttr) { 0063 setIn1BaseValue(value); 0064 } else if (attr->name() == SVGNames::in2Attr) { 0065 setIn2BaseValue(value); 0066 } else { 0067 SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr); 0068 } 0069 } 0070 0071 SVGFEBlend *SVGFEBlendElement::filterEffect(SVGResourceFilter *filter) const 0072 { 0073 if (!m_filterEffect) { 0074 m_filterEffect = new SVGFEBlend(filter); 0075 } 0076 0077 m_filterEffect->setBlendMode((SVGBlendModeType) mode()); 0078 m_filterEffect->setIn(in1()); 0079 m_filterEffect->setIn2(in2()); 0080 setStandardAttributes(m_filterEffect); 0081 return m_filterEffect; 0082 } 0083 0084 } 0085 0086 #endif // ENABLE(SVG) 0087