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#include "core/svg/SVGAnimatedEnumeration.h" 24#include "core/svg/SVGAnimatedNumber.h" 25#include "core/svg/SVGFilterPrimitiveStandardAttributes.h" 26#include "platform/graphics/filters/FEDisplacementMap.h" 27 28namespace WebCore { 29 30template<> 31struct SVGPropertyTraits<ChannelSelectorType> { 32 static unsigned highestEnumValue() { return CHANNEL_A; } 33 34 static String toString(ChannelSelectorType type) 35 { 36 switch (type) { 37 case CHANNEL_UNKNOWN: 38 return emptyString(); 39 case CHANNEL_R: 40 return "R"; 41 case CHANNEL_G: 42 return "G"; 43 case CHANNEL_B: 44 return "B"; 45 case CHANNEL_A: 46 return "A"; 47 } 48 49 ASSERT_NOT_REACHED(); 50 return emptyString(); 51 } 52 53 static ChannelSelectorType fromString(const String& value) 54 { 55 if (value == "R") 56 return CHANNEL_R; 57 if (value == "G") 58 return CHANNEL_G; 59 if (value == "B") 60 return CHANNEL_B; 61 if (value == "A") 62 return CHANNEL_A; 63 return CHANNEL_UNKNOWN; 64 } 65}; 66 67class SVGFEDisplacementMapElement FINAL : public SVGFilterPrimitiveStandardAttributes { 68public: 69 static PassRefPtr<SVGFEDisplacementMapElement> create(Document&); 70 71 static ChannelSelectorType stringToChannel(const String&); 72 73private: 74 SVGFEDisplacementMapElement(Document&); 75 76 bool isSupportedAttribute(const QualifiedName&); 77 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE; 78 virtual bool setFilterEffectAttribute(FilterEffect*, const QualifiedName& attrName); 79 virtual void svgAttributeChanged(const QualifiedName&); 80 virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*); 81 82 BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGFEDisplacementMapElement) 83 DECLARE_ANIMATED_STRING(In1, in1) 84 DECLARE_ANIMATED_STRING(In2, in2) 85 DECLARE_ANIMATED_ENUMERATION(XChannelSelector, xChannelSelector, ChannelSelectorType) 86 DECLARE_ANIMATED_ENUMERATION(YChannelSelector, yChannelSelector, ChannelSelectorType) 87 DECLARE_ANIMATED_NUMBER(Scale, scale) 88 END_DECLARE_ANIMATED_PROPERTIES 89}; 90 91} // namespace WebCore 92 93#endif // SVGFEDisplacementMapElement_h 94