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