~ubuntu-branches/ubuntu/maverick/webkit/maverick

« back to all changes in this revision

Viewing changes to WebCore/ksvg2/svg/SVGFECompositeElement.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mike Hommey
  • Date: 2007-08-19 15:54:12 UTC
  • Revision ID: james.westby@ubuntu.com-20070819155412-uxxg1h9plpghmtbi
Tags: upstream-0~svn25144
ImportĀ upstreamĀ versionĀ 0~svn25144

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
 
3
                  2004, 2005, 2006 Rob Buis <buis@kde.org>
 
4
 
 
5
    This file is part of the KDE project
 
6
 
 
7
    This library is free software; you can redistribute it and/or
 
8
    modify it under the terms of the GNU Library General Public
 
9
    License as published by the Free Software Foundation; either
 
10
    version 2 of the License, or (at your option) any later version.
 
11
 
 
12
    This library is distributed in the hope that it will be useful,
 
13
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
15
    Library General Public License for more details.
 
16
 
 
17
    You should have received a copy of the GNU Library General Public License
 
18
    along with this library; see the file COPYING.LIB.  If not, write to
 
19
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
20
    Boston, MA 02111-1307, USA.
 
21
*/
 
22
 
 
23
#include "config.h"
 
24
 
 
25
#if ENABLE(SVG) && ENABLE(SVG_EXPERIMENTAL_FEATURES)
 
26
#include "SVGFECompositeElement.h"
 
27
 
 
28
#include "SVGNames.h"
 
29
#include "SVGResourceFilter.h"
 
30
 
 
31
namespace WebCore {
 
32
 
 
33
SVGFECompositeElement::SVGFECompositeElement(const QualifiedName& tagName, Document* doc)
 
34
    : SVGFilterPrimitiveStandardAttributes(tagName, doc)
 
35
    , m__operator(0)
 
36
    , m_k1(0.0)
 
37
    , m_k2(0.0)
 
38
    , m_k3(0.0)
 
39
    , m_k4(0.0)
 
40
    , m_filterEffect(0)
 
41
{
 
42
}
 
43
 
 
44
SVGFECompositeElement::~SVGFECompositeElement()
 
45
{
 
46
    delete m_filterEffect;
 
47
}
 
48
 
 
49
ANIMATED_PROPERTY_DEFINITIONS(SVGFECompositeElement, String, String, string, In1, in1, SVGNames::inAttr.localName(), m_in1)
 
50
ANIMATED_PROPERTY_DEFINITIONS(SVGFECompositeElement, String, String, string, In2, in2, SVGNames::in2Attr.localName(), m_in2)
 
51
ANIMATED_PROPERTY_DEFINITIONS(SVGFECompositeElement, int, Enumeration, enumeration, _operator, _operator, SVGNames::operatorAttr.localName(), m__operator)
 
52
ANIMATED_PROPERTY_DEFINITIONS(SVGFECompositeElement, double, Number, number, K1, k1, SVGNames::k1Attr.localName(), m_k1)
 
53
ANIMATED_PROPERTY_DEFINITIONS(SVGFECompositeElement, double, Number, number, K2, k2, SVGNames::k2Attr.localName(), m_k2)
 
54
ANIMATED_PROPERTY_DEFINITIONS(SVGFECompositeElement, double, Number, number, K3, k3, SVGNames::k3Attr.localName(), m_k3)
 
55
ANIMATED_PROPERTY_DEFINITIONS(SVGFECompositeElement, double, Number, number, K4, k4, SVGNames::k4Attr.localName(), m_k4)
 
56
 
 
57
void SVGFECompositeElement::parseMappedAttribute(MappedAttribute *attr)
 
58
{
 
59
    const String& value = attr->value();
 
60
    if (attr->name() == SVGNames::operatorAttr)
 
61
    {
 
62
        if (value == "over")
 
63
            set_operatorBaseValue(SVG_FECOMPOSITE_OPERATOR_OVER);
 
64
        else if (value == "in")
 
65
            set_operatorBaseValue(SVG_FECOMPOSITE_OPERATOR_IN);
 
66
        else if (value == "out")
 
67
            set_operatorBaseValue(SVG_FECOMPOSITE_OPERATOR_OUT);
 
68
        else if (value == "atop")
 
69
            set_operatorBaseValue(SVG_FECOMPOSITE_OPERATOR_ATOP);
 
70
        else if (value == "xor")
 
71
            set_operatorBaseValue(SVG_FECOMPOSITE_OPERATOR_XOR);
 
72
        else if (value == "arithmetic")
 
73
            set_operatorBaseValue(SVG_FECOMPOSITE_OPERATOR_ARITHMETIC);
 
74
    }
 
75
    else if (attr->name() == SVGNames::inAttr)
 
76
        setIn1BaseValue(value);
 
77
    else if (attr->name() == SVGNames::in2Attr)
 
78
        setIn2BaseValue(value);
 
79
    else if (attr->name() == SVGNames::k1Attr)
 
80
        setK1BaseValue(value.toDouble());
 
81
    else if (attr->name() == SVGNames::k2Attr)
 
82
        setK2BaseValue(value.toDouble());
 
83
    else if (attr->name() == SVGNames::k3Attr)
 
84
        setK3BaseValue(value.toDouble());
 
85
    else if (attr->name() == SVGNames::k4Attr)
 
86
        setK4BaseValue(value.toDouble());
 
87
    else
 
88
        SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
 
89
}
 
90
 
 
91
SVGFEComposite* SVGFECompositeElement::filterEffect() const
 
92
{
 
93
    if (!m_filterEffect)
 
94
        m_filterEffect = static_cast<SVGFEComposite*>(SVGResourceFilter::createFilterEffect(FE_COMPOSITE));
 
95
    if (!m_filterEffect)
 
96
        return 0;
 
97
    m_filterEffect->setOperation((SVGCompositeOperationType) _operator());
 
98
    m_filterEffect->setIn(in1());
 
99
    m_filterEffect->setIn2(in2());
 
100
    setStandardAttributes(m_filterEffect);
 
101
    m_filterEffect->setK1(k1());
 
102
    m_filterEffect->setK2(k2());
 
103
    m_filterEffect->setK3(k3());
 
104
    m_filterEffect->setK4(k4());
 
105
    return m_filterEffect;
 
106
}
 
107
 
 
108
}
 
109
 
 
110
#endif // ENABLE(SVG)
 
111
 
 
112
// vim:ts=4:noet