• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2004, 2005, 2007 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  */
20 
21 #ifndef SVGFECompositeElement_h
22 #define SVGFECompositeElement_h
23 
24 #include "core/svg/SVGAnimatedEnumeration.h"
25 #include "core/svg/SVGAnimatedNumber.h"
26 #include "core/svg/SVGFilterPrimitiveStandardAttributes.h"
27 #include "platform/graphics/filters/FEComposite.h"
28 
29 namespace WebCore {
30 
31 template<>
32 struct SVGPropertyTraits<CompositeOperationType> {
33     static unsigned highestEnumValue() { return FECOMPOSITE_OPERATOR_ARITHMETIC; }
34 
35     static String toString(CompositeOperationType type)
36     {
37         switch (type) {
38         case FECOMPOSITE_OPERATOR_UNKNOWN:
39             return emptyString();
40         case FECOMPOSITE_OPERATOR_OVER:
41             return "over";
42         case FECOMPOSITE_OPERATOR_IN:
43             return "in";
44         case FECOMPOSITE_OPERATOR_OUT:
45             return "out";
46         case FECOMPOSITE_OPERATOR_ATOP:
47             return "atop";
48         case FECOMPOSITE_OPERATOR_XOR:
49             return "xor";
50         case FECOMPOSITE_OPERATOR_ARITHMETIC:
51             return "arithmetic";
52         }
53 
54         ASSERT_NOT_REACHED();
55         return emptyString();
56     }
57 
58     static CompositeOperationType fromString(const String& value)
59     {
60         if (value == "over")
61             return FECOMPOSITE_OPERATOR_OVER;
62         if (value == "in")
63             return FECOMPOSITE_OPERATOR_IN;
64         if (value == "out")
65             return FECOMPOSITE_OPERATOR_OUT;
66         if (value == "atop")
67             return FECOMPOSITE_OPERATOR_ATOP;
68         if (value == "xor")
69             return FECOMPOSITE_OPERATOR_XOR;
70         if (value == "arithmetic")
71             return FECOMPOSITE_OPERATOR_ARITHMETIC;
72         return FECOMPOSITE_OPERATOR_UNKNOWN;
73     }
74 };
75 
76 class SVGFECompositeElement FINAL : public SVGFilterPrimitiveStandardAttributes {
77 public:
78     static PassRefPtr<SVGFECompositeElement> create(Document&);
79 
80 private:
81     explicit SVGFECompositeElement(Document&);
82 
83     bool isSupportedAttribute(const QualifiedName&);
84     virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
85     virtual bool setFilterEffectAttribute(FilterEffect*, const QualifiedName&);
86     virtual void svgAttributeChanged(const QualifiedName&);
87     virtual PassRefPtr<FilterEffect> build(SVGFilterBuilder*, Filter*);
88 
89     BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGFECompositeElement)
90         DECLARE_ANIMATED_STRING(In1, in1)
91         DECLARE_ANIMATED_STRING(In2, in2)
92         DECLARE_ANIMATED_ENUMERATION(SVGOperator, svgOperator, CompositeOperationType)
93         DECLARE_ANIMATED_NUMBER(K1, k1)
94         DECLARE_ANIMATED_NUMBER(K2, k2)
95         DECLARE_ANIMATED_NUMBER(K3, k3)
96         DECLARE_ANIMATED_NUMBER(K4, k4)
97     END_DECLARE_ANIMATED_PROPERTIES
98 };
99 
100 } // namespace WebCore
101 
102 #endif
103