1/* 2 * Copyright (C) 2006 Oliver Hunt <oliver@nerget.com> 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public License 15 * along with this library; see the file COPYING.LIB. If not, write to 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 20#ifndef SVGFEDisplacementMapElement_h 21#define SVGFEDisplacementMapElement_h 22 23#if ENABLE(FILTERS) 24#include "FEDisplacementMap.h" 25#include "SVGAnimatedEnumeration.h" 26#include "SVGAnimatedNumber.h" 27#include "SVGFilterPrimitiveStandardAttributes.h" 28 29namespace WebCore { 30 31template<> 32struct SVGPropertyTraits<ChannelSelectorType> { 33 static unsigned highestEnumValue() { return CHANNEL_A; } 34 35 static String toString(ChannelSelectorType type) 36 { 37 switch (type) { 38 case CHANNEL_UNKNOWN: 39 return emptyString(); 40 case CHANNEL_R: 41 return "R"; 42 case CHANNEL_G: 43 return "G"; 44 case CHANNEL_B: 45 return "B"; 46 case CHANNEL_A: 47 return "A"; 48 } 49 50 ASSERT_NOT_REACHED(); 51 return emptyString(); 52 } 53 54 static ChannelSelectorType fromString(const String& value) 55 { 56 if (value == "R") 57 return CHANNEL_R; 58 if (value == "G") 59 return CHANNEL_G; 60 if (value == "B") 61 return CHANNEL_B; 62 if (value == "A") 63 return CHANNEL_A; 64 return CHANNEL_UNKNOWN; 65 } 66}; 67 68class SVGFEDisplacementMapElement final : public SVGFilterPrimitiveStandardAttributes { 69public: 70 static PassRefPtr<SVGFEDisplacementMapElement> create(const QualifiedName&, Document&); 71 72 static ChannelSelectorType stringToChannel(const String&); 73 74private: 75 SVGFEDisplacementMapElement(const QualifiedName& tagName, Document&); 76 77 bool isSupportedAttribute(const QualifiedName&); 78 virtual void parseAttribute(const QualifiedName&, const AtomicString&) override; 79 virtual bool setFilterEffectAttribute(FilterEffect*, const QualifiedName& attrName) override; 80 virtual void svgAttributeChanged(const QualifiedName&) override; 81 virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*) override; 82 83 BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGFEDisplacementMapElement) 84 DECLARE_ANIMATED_STRING(In1, in1) 85 DECLARE_ANIMATED_STRING(In2, in2) 86 DECLARE_ANIMATED_ENUMERATION(XChannelSelector, xChannelSelector, ChannelSelectorType) 87 DECLARE_ANIMATED_ENUMERATION(YChannelSelector, yChannelSelector, ChannelSelectorType) 88 DECLARE_ANIMATED_NUMBER(Scale, scale) 89 END_DECLARE_ANIMATED_PROPERTIES 90}; 91 92} // namespace WebCore 93 94#endif // ENABLE(FILTERS) 95#endif // SVGFEDisplacementMapElement_h 96