1 /* 2 * Copyright (C) 2009 Dirk Schulze <krit (at) webkit.org> 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 SVGFEConvolveMatrixElement_h 21 #define SVGFEConvolveMatrixElement_h 22 23 #include "core/platform/graphics/filters/FEConvolveMatrix.h" 24 #include "core/svg/SVGAnimatedBoolean.h" 25 #include "core/svg/SVGAnimatedEnumeration.h" 26 #include "core/svg/SVGAnimatedInteger.h" 27 #include "core/svg/SVGAnimatedNumber.h" 28 #include "core/svg/SVGAnimatedNumberList.h" 29 #include "core/svg/SVGFilterPrimitiveStandardAttributes.h" 30 31 namespace WebCore { 32 33 template<> 34 struct SVGPropertyTraits<EdgeModeType> { 35 static unsigned highestEnumValue() { return EDGEMODE_NONE; } 36 37 static String toString(EdgeModeType type) 38 { 39 switch (type) { 40 case EDGEMODE_UNKNOWN: 41 return emptyString(); 42 case EDGEMODE_DUPLICATE: 43 return "duplicate"; 44 case EDGEMODE_WRAP: 45 return "wrap"; 46 case EDGEMODE_NONE: 47 return "none"; 48 } 49 50 ASSERT_NOT_REACHED(); 51 return emptyString(); 52 } 53 54 static EdgeModeType fromString(const String& value) 55 { 56 if (value == "duplicate") 57 return EDGEMODE_DUPLICATE; 58 if (value == "wrap") 59 return EDGEMODE_WRAP; 60 if (value == "none") 61 return EDGEMODE_NONE; 62 return EDGEMODE_UNKNOWN; 63 } 64 }; 65 66 class SVGFEConvolveMatrixElement FINAL : public SVGFilterPrimitiveStandardAttributes { 67 public: 68 static PassRefPtr<SVGFEConvolveMatrixElement> create(const QualifiedName&, Document*); 69 70 void setOrder(float orderX, float orderY); 71 void setKernelUnitLength(float kernelUnitLengthX, float kernelUnitLengthY); 72 73 private: 74 SVGFEConvolveMatrixElement(const QualifiedName&, Document*); 75 76 bool isSupportedAttribute(const QualifiedName&); 77 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE; 78 virtual bool setFilterEffectAttribute(FilterEffect*, const QualifiedName&); 79 virtual void svgAttributeChanged(const QualifiedName&); 80 virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*); 81 82 static const AtomicString& orderXIdentifier(); 83 static const AtomicString& orderYIdentifier(); 84 static const AtomicString& kernelUnitLengthXIdentifier(); 85 static const AtomicString& kernelUnitLengthYIdentifier(); 86 87 BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGFEConvolveMatrixElement) 88 DECLARE_ANIMATED_STRING(In1, in1) 89 DECLARE_ANIMATED_INTEGER(OrderX, orderX) 90 DECLARE_ANIMATED_INTEGER(OrderY, orderY) 91 DECLARE_ANIMATED_NUMBER_LIST(KernelMatrix, kernelMatrix) 92 DECLARE_ANIMATED_NUMBER(Divisor, divisor) 93 DECLARE_ANIMATED_NUMBER(Bias, bias) 94 DECLARE_ANIMATED_INTEGER(TargetX, targetX) 95 DECLARE_ANIMATED_INTEGER(TargetY, targetY) 96 DECLARE_ANIMATED_ENUMERATION(EdgeMode, edgeMode, EdgeModeType) 97 DECLARE_ANIMATED_NUMBER(KernelUnitLengthX, kernelUnitLengthX) 98 DECLARE_ANIMATED_NUMBER(KernelUnitLengthY, kernelUnitLengthY) 99 DECLARE_ANIMATED_BOOLEAN(PreserveAlpha, preserveAlpha) 100 END_DECLARE_ANIMATED_PROPERTIES 101 }; 102 103 } // namespace WebCore 104 105 #endif 106