KHtml

SVGFEComponentTransferElement.cpp
1 /*
2  Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <[email protected]>
3  2004, 2005 Rob Buis <[email protected]>
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., 51 Franklin Street, Fifth Floor,
20  Boston, MA 02110-1301, USA.
21 */
22 
23 #if ENABLE(SVG) && ENABLE(SVG_FILTERS)
24 #include "SVGFEComponentTransferElement.h"
25 
26 #include "Attr.h"
27 #include "SVGNames.h"
28 #include "SVGRenderStyle.h"
29 #include "SVGFEFuncRElement.h"
30 #include "SVGFEFuncGElement.h"
31 #include "SVGFEFuncBElement.h"
32 #include "SVGFEFuncAElement.h"
33 #include "SVGResourceFilter.h"
34 
35 namespace WebCore
36 {
37 
38 SVGFEComponentTransferElement::SVGFEComponentTransferElement(const QualifiedName &tagName, Document *doc)
39  : SVGFilterPrimitiveStandardAttributes(tagName, doc)
40  , m_filterEffect(0)
41 {
42 }
43 
44 SVGFEComponentTransferElement::~SVGFEComponentTransferElement()
45 {
46  delete m_filterEffect;
47 }
48 
49 ANIMATED_PROPERTY_DEFINITIONS(SVGFEComponentTransferElement, String, String, string, In1, in1, SVGNames::inAttr, m_in1)
50 
51 void SVGFEComponentTransferElement::parseMappedAttribute(MappedAttribute *attr)
52 {
53  const String &value = attr->value();
54  if (attr->name() == SVGNames::inAttr) {
55  setIn1BaseValue(value);
56  } else {
57  SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
58  }
59 }
60 
61 SVGFEComponentTransfer *SVGFEComponentTransferElement::filterEffect(SVGResourceFilter *filter) const
62 {
63  if (!m_filterEffect) {
64  m_filterEffect = new SVGFEComponentTransfer(filter);
65  }
66 
67  m_filterEffect->setIn(in1());
68  setStandardAttributes(m_filterEffect);
69 
70  for (Node *n = firstChild(); n != 0; n = n->nextSibling()) {
71  if (n->hasTagName(SVGNames::feFuncRTag)) {
72  m_filterEffect->setRedFunction(static_cast<SVGFEFuncRElement *>(n)->transferFunction());
73  } else if (n->hasTagName(SVGNames::feFuncGTag)) {
74  m_filterEffect->setGreenFunction(static_cast<SVGFEFuncGElement *>(n)->transferFunction());
75  } else if (n->hasTagName(SVGNames::feFuncBTag)) {
76  m_filterEffect->setBlueFunction(static_cast<SVGFEFuncBElement *>(n)->transferFunction());
77  } else if (n->hasTagName(SVGNames::feFuncATag)) {
78  m_filterEffect->setAlphaFunction(static_cast<SVGFEFuncAElement *>(n)->transferFunction());
79  }
80  }
81 
82  return m_filterEffect;
83 }
84 
85 }
86 
87 #endif // ENABLE(SVG)
88 
MESSAGECORE_EXPORT KMime::Content * firstChild(const KMime::Content *node)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Oct 16 2021 22:48:01 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.