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