blob: ec6e3d2b88853f86e19e94e8e66b646d2a9687c5 [file] [log] [blame]
darinb9481ed2006-03-20 02:57:59 +00001/*
zimmermann@webkit.org711245f2010-08-03 19:39:01 +00002 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
darinb9481ed2006-03-20 02:57:59 +000020
eseidel8eddecf2007-01-16 00:49:43 +000021#ifndef SVGComponentTransferFunctionElement_h
22#define SVGComponentTransferFunctionElement_h
darinb9481ed2006-03-20 02:57:59 +000023
krit@webkit.orgbfb80bf2009-05-28 22:10:29 +000024#if ENABLE(SVG) && ENABLE(FILTERS)
zimmermann@webkit.orgf08b5ba2010-10-30 13:23:55 +000025#include "FEComponentTransfer.h"
zimmermann@webkit.org15de2b82010-12-02 15:19:03 +000026#include "SVGAnimatedEnumeration.h"
zimmermann@webkit.orge5a72c62010-12-01 16:36:29 +000027#include "SVGAnimatedNumber.h"
zimmermann@webkit.orgca9551e2010-12-01 15:41:53 +000028#include "SVGAnimatedNumberList.h"
darinb9481ed2006-03-20 02:57:59 +000029
zimmermann@webkit.org057741d2008-07-19 15:46:48 +000030namespace WebCore {
darinb9481ed2006-03-20 02:57:59 +000031
zimmermann@webkit.org94630af2011-05-18 15:35:36 +000032template<>
33struct SVGPropertyTraits<ComponentTransferType> {
34 static ComponentTransferType highestEnumValue() { return FECOMPONENTTRANSFER_TYPE_GAMMA; }
35
36 static String toString(ComponentTransferType type)
37 {
38 switch (type) {
39 case FECOMPONENTTRANSFER_TYPE_UNKNOWN:
40 return emptyString();
41 case FECOMPONENTTRANSFER_TYPE_IDENTITY:
42 return "identity";
43 case FECOMPONENTTRANSFER_TYPE_TABLE:
44 return "table";
45 case FECOMPONENTTRANSFER_TYPE_DISCRETE:
46 return "discrete";
47 case FECOMPONENTTRANSFER_TYPE_LINEAR:
48 return "linear";
49 case FECOMPONENTTRANSFER_TYPE_GAMMA:
50 return "gamma";
51 }
52
53 ASSERT_NOT_REACHED();
54 return emptyString();
55 }
56
57 static ComponentTransferType fromString(const String& value)
58 {
59 if (value == "identity")
60 return FECOMPONENTTRANSFER_TYPE_IDENTITY;
61 if (value == "table")
62 return FECOMPONENTTRANSFER_TYPE_TABLE;
63 if (value == "discrete")
64 return FECOMPONENTTRANSFER_TYPE_DISCRETE;
65 if (value == "linear")
66 return FECOMPONENTTRANSFER_TYPE_LINEAR;
67 if (value == "gamma")
68 return FECOMPONENTTRANSFER_TYPE_GAMMA;
69 return FECOMPONENTTRANSFER_TYPE_UNKNOWN;
70 }
71};
72
zimmermann@webkit.orge1c7c582011-07-07 14:18:01 +000073class SVGComponentTransferFunctionElement : public SVGElement {
74public:
75 ComponentTransferFunction transferFunction() const;
76
77protected:
78 SVGComponentTransferFunctionElement(const QualifiedName&, Document*);
79
zimmermann@webkit.orge1c7c582011-07-07 14:18:01 +000080 bool isSupportedAttribute(const QualifiedName&);
kling@webkit.org8a3d4af2012-02-06 02:21:57 +000081 virtual void parseAttribute(Attribute*) OVERRIDE;
reni@webkit.orga0e31742011-10-13 16:33:19 +000082 virtual void svgAttributeChanged(const QualifiedName&);
zimmermann@webkit.orge1c7c582011-07-07 14:18:01 +000083
84private:
zimmermann@webkit.orga2857422011-07-09 11:26:10 +000085 BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGComponentTransferFunctionElement)
86 DECLARE_ANIMATED_ENUMERATION(Type, type, ComponentTransferType)
87 DECLARE_ANIMATED_NUMBER_LIST(TableValues, tableValues)
88 DECLARE_ANIMATED_NUMBER(Slope, slope)
89 DECLARE_ANIMATED_NUMBER(Intercept, intercept)
90 DECLARE_ANIMATED_NUMBER(Amplitude, amplitude)
91 DECLARE_ANIMATED_NUMBER(Exponent, exponent)
92 DECLARE_ANIMATED_NUMBER(Offset, offset)
93 END_DECLARE_ANIMATED_PROPERTIES
zimmermann@webkit.orge1c7c582011-07-07 14:18:01 +000094};
95
weinigab5f09e2006-07-29 23:15:25 +000096} // namespace WebCore
darinb9481ed2006-03-20 02:57:59 +000097
krit@webkit.orgbfb80bf2009-05-28 22:10:29 +000098#endif // ENABLE(SVG) && ENABLE(FILTERS)
darinb9481ed2006-03-20 02:57:59 +000099#endif