1/* 2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 3 * Copyright (C) 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#ifndef SVGFEBlendElement_h 22#define SVGFEBlendElement_h 23 24#include "core/svg/SVGAnimatedEnumeration.h" 25#include "core/svg/SVGFilterPrimitiveStandardAttributes.h" 26#include "platform/graphics/filters/FEBlend.h" 27 28namespace WebCore { 29 30template<> 31struct SVGPropertyTraits<BlendModeType> { 32 static unsigned highestEnumValue() { return FEBLEND_MODE_LIGHTEN; } 33 34 static String toString(BlendModeType type) 35 { 36 switch (type) { 37 case FEBLEND_MODE_UNKNOWN: 38 return emptyString(); 39 case FEBLEND_MODE_NORMAL: 40 return "normal"; 41 case FEBLEND_MODE_MULTIPLY: 42 return "multiply"; 43 case FEBLEND_MODE_SCREEN: 44 return "screen"; 45 case FEBLEND_MODE_DARKEN: 46 return "darken"; 47 case FEBLEND_MODE_LIGHTEN: 48 return "lighten"; 49 } 50 51 ASSERT_NOT_REACHED(); 52 return emptyString(); 53 } 54 55 static BlendModeType fromString(const String& value) 56 { 57 if (value == "normal") 58 return FEBLEND_MODE_NORMAL; 59 if (value == "multiply") 60 return FEBLEND_MODE_MULTIPLY; 61 if (value == "screen") 62 return FEBLEND_MODE_SCREEN; 63 if (value == "darken") 64 return FEBLEND_MODE_DARKEN; 65 if (value == "lighten") 66 return FEBLEND_MODE_LIGHTEN; 67 return FEBLEND_MODE_UNKNOWN; 68 } 69}; 70 71class SVGFEBlendElement FINAL : public SVGFilterPrimitiveStandardAttributes { 72public: 73 static PassRefPtr<SVGFEBlendElement> create(Document&); 74 75private: 76 explicit SVGFEBlendElement(Document&); 77 78 bool isSupportedAttribute(const QualifiedName&); 79 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE; 80 virtual bool setFilterEffectAttribute(FilterEffect*, const QualifiedName& attrName); 81 virtual void svgAttributeChanged(const QualifiedName&); 82 virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*); 83 84 BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGFEBlendElement) 85 DECLARE_ANIMATED_STRING(In1, in1) 86 DECLARE_ANIMATED_STRING(In2, in2) 87 DECLARE_ANIMATED_ENUMERATION(Mode, mode, BlendModeType) 88 END_DECLARE_ANIMATED_PROPERTIES 89}; 90 91} // namespace WebCore 92 93#endif 94