blob: a64f819692e55f129b0f666954959887726728d1 [file] [log] [blame]
darinb9481ed2006-03-20 02:57:59 +00001/*
zimmermann@webkit.org711245f2010-08-03 19:39:01 +00002 * 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.
darinb9481ed2006-03-20 02:57:59 +000018 */
19
eseidel8eddecf2007-01-16 00:49:43 +000020#ifndef SVGFEDisplacementMapElement_h
21#define SVGFEDisplacementMapElement_h
darinb9481ed2006-03-20 02:57:59 +000022
krit@webkit.orga64eca02010-09-22 07:42:12 +000023#include "FEDisplacementMap.h"
zimmermann@webkit.org15de2b82010-12-02 15:19:03 +000024#include "SVGAnimatedEnumeration.h"
zimmermann@webkit.orge5a72c62010-12-01 16:36:29 +000025#include "SVGAnimatedNumber.h"
rwlbuis79983122006-10-09 07:40:41 +000026#include "SVGFilterPrimitiveStandardAttributes.h"
darinb9481ed2006-03-20 02:57:59 +000027
darind18e72a2006-03-21 01:15:36 +000028namespace WebCore {
zimmermann@webkit.orge1c7c582011-07-07 14:18:01 +000029
zimmermann@webkit.org94630af2011-05-18 15:35:36 +000030template<>
31struct SVGPropertyTraits<ChannelSelectorType> {
zimmermann@webkit.orgf941d3c2012-04-03 11:26:50 +000032 static unsigned highestEnumValue() { return CHANNEL_A; }
zimmermann@webkit.org94630af2011-05-18 15:35:36 +000033
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
andersca@apple.com16d2dd42014-01-16 23:08:24 +000067class SVGFEDisplacementMapElement final : public SVGFilterPrimitiveStandardAttributes {
zimmermann@webkit.orge1c7c582011-07-07 14:18:01 +000068public:
weinig@apple.com10923572015-01-07 20:56:24 +000069 static Ref<SVGFEDisplacementMapElement> create(const QualifiedName&, Document&);
zimmermann@webkit.orge1c7c582011-07-07 14:18:01 +000070
71 static ChannelSelectorType stringToChannel(const String&);
72
73private:
weinig@apple.com52e786e2013-09-15 18:06:06 +000074 SVGFEDisplacementMapElement(const QualifiedName& tagName, Document&);
zimmermann@webkit.orge1c7c582011-07-07 14:18:01 +000075
commit-queue@webkit.org2dfe6cb2014-01-16 19:42:50 +000076 virtual void parseAttribute(const QualifiedName&, const AtomicString&) override;
andersca@apple.comca796ab2014-01-17 03:23:06 +000077 virtual bool setFilterEffectAttribute(FilterEffect*, const QualifiedName& attrName) override;
78 virtual void svgAttributeChanged(const QualifiedName&) override;
commit-queue@webkit.org98d1e372015-04-27 03:51:23 +000079 virtual RefPtr<FilterEffect> build(SVGFilterBuilder*, Filter&) override;
zimmermann@webkit.orge1c7c582011-07-07 14:18:01 +000080
zimmermann@webkit.orga2857422011-07-09 11:26:10 +000081 BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGFEDisplacementMapElement)
82 DECLARE_ANIMATED_STRING(In1, in1)
83 DECLARE_ANIMATED_STRING(In2, in2)
84 DECLARE_ANIMATED_ENUMERATION(XChannelSelector, xChannelSelector, ChannelSelectorType)
85 DECLARE_ANIMATED_ENUMERATION(YChannelSelector, yChannelSelector, ChannelSelectorType)
86 DECLARE_ANIMATED_NUMBER(Scale, scale)
87 END_DECLARE_ANIMATED_PROPERTIES
zimmermann@webkit.orge1c7c582011-07-07 14:18:01 +000088};
89
weinigab5f09e2006-07-29 23:15:25 +000090} // namespace WebCore
darinb9481ed2006-03-20 02:57:59 +000091
eseidel8eddecf2007-01-16 00:49:43 +000092#endif // SVGFEDisplacementMapElement_h