Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / svg / SVGFEConvolveMatrixElement.h
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 #include "core/svg/SVGAnimatedBoolean.h"
24 #include "core/svg/SVGAnimatedEnumeration.h"
25 #include "core/svg/SVGAnimatedInteger.h"
26 #include "core/svg/SVGAnimatedIntegerOptionalInteger.h"
27 #include "core/svg/SVGAnimatedNumber.h"
28 #include "core/svg/SVGAnimatedNumberList.h"
29 #include "core/svg/SVGAnimatedNumberOptionalNumber.h"
30 #include "core/svg/SVGFilterPrimitiveStandardAttributes.h"
31 #include "platform/graphics/filters/FEConvolveMatrix.h"
32
33 namespace WebCore {
34
35 template<>
36 struct SVGPropertyTraits<EdgeModeType> {
37     static unsigned highestEnumValue() { return EDGEMODE_NONE; }
38
39     static String toString(EdgeModeType type)
40     {
41         switch (type) {
42         case EDGEMODE_UNKNOWN:
43             return emptyString();
44         case EDGEMODE_DUPLICATE:
45             return "duplicate";
46         case EDGEMODE_WRAP:
47             return "wrap";
48         case EDGEMODE_NONE:
49             return "none";
50         }
51
52         ASSERT_NOT_REACHED();
53         return emptyString();
54     }
55
56     static EdgeModeType fromString(const String& value)
57     {
58         if (value == "duplicate")
59             return EDGEMODE_DUPLICATE;
60         if (value == "wrap")
61             return EDGEMODE_WRAP;
62         if (value == "none")
63             return EDGEMODE_NONE;
64         return EDGEMODE_UNKNOWN;
65     }
66 };
67
68 class SVGFEConvolveMatrixElement FINAL : public SVGFilterPrimitiveStandardAttributes {
69 public:
70     static PassRefPtr<SVGFEConvolveMatrixElement> create(Document&);
71
72     SVGAnimatedBoolean* preserveAlpha() { return m_preserveAlpha.get(); }
73     SVGAnimatedNumber* divisor() { return m_divisor.get(); }
74     SVGAnimatedNumber* bias() { return m_bias.get(); }
75     SVGAnimatedNumber* kernelUnitLengthX() { return m_kernelUnitLength->firstNumber(); }
76     SVGAnimatedNumber* kernelUnitLengthY() { return m_kernelUnitLength->secondNumber(); }
77     SVGAnimatedNumberList* kernelMatrix() { return m_kernelMatrix.get(); }
78     SVGAnimatedString* in1() { return m_in1.get(); }
79     SVGAnimatedInteger* orderX() { return m_order->firstInteger(); }
80     SVGAnimatedInteger* orderY() { return m_order->secondInteger(); }
81     SVGAnimatedInteger* targetX() { return m_targetX.get(); }
82     SVGAnimatedInteger* targetY() { return m_targetY.get(); }
83
84 private:
85     explicit SVGFEConvolveMatrixElement(Document&);
86
87     bool isSupportedAttribute(const QualifiedName&);
88     virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
89     virtual bool setFilterEffectAttribute(FilterEffect*, const QualifiedName&) OVERRIDE;
90     virtual void svgAttributeChanged(const QualifiedName&) OVERRIDE;
91     virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*) OVERRIDE;
92
93     RefPtr<SVGAnimatedNumber> m_bias;
94     RefPtr<SVGAnimatedNumber> m_divisor;
95     RefPtr<SVGAnimatedString> m_in1;
96     RefPtr<SVGAnimatedNumberList> m_kernelMatrix;
97     RefPtr<SVGAnimatedNumberOptionalNumber> m_kernelUnitLength;
98     RefPtr<SVGAnimatedIntegerOptionalInteger> m_order;
99     RefPtr<SVGAnimatedBoolean> m_preserveAlpha;
100     RefPtr<SVGAnimatedInteger> m_targetX;
101     RefPtr<SVGAnimatedInteger> m_targetY;
102     BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGFEConvolveMatrixElement)
103         DECLARE_ANIMATED_ENUMERATION(EdgeMode, edgeMode, EdgeModeType)
104     END_DECLARE_ANIMATED_PROPERTIES
105 };
106
107 } // namespace WebCore
108
109 #endif