KHtml

SVGFilterEffect.cpp
1 /*
2  Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <[email protected]>
3  2004, 2005 Rob Buis <[email protected]>
4  2005 Eric Seidel <[email protected]>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  aint with this library; see the file COPYING.LIB. If not, write to
18  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  Boston, MA 02110-1301, USA.
20 */
21 
22 #if ENABLE(SVG) && ENABLE(SVG_FILTERS)
23 #include "SVGFilterEffect.h"
24 
25 #include "SVGRenderTreeAsText.h"
26 #include "SVGResourceFilter.h"
27 
28 namespace WebCore
29 {
30 
31 SVGFilterEffect::SVGFilterEffect(SVGResourceFilter *filter)
32  : m_filter(filter)
33  , m_xBBoxMode(false)
34  , m_yBBoxMode(false)
35  , m_widthBBoxMode(false)
36  , m_heightBBoxMode(false)
37 {
38 }
39 
40 FloatRect SVGFilterEffect::primitiveBBoxForFilterBBox(const FloatRect &filterBBox, const FloatRect &itemBBox) const
41 {
42  FloatRect subRegionBBox = subRegion();
43  FloatRect useBBox = filterBBox;
44 
45  ASSERT(m_filter);
46  if (!m_filter) {
47  return FloatRect();
48  }
49 
50  if (m_filter->effectBoundingBoxMode()) {
51  if (!m_filter->filterBoundingBoxMode()) {
52  useBBox = itemBBox;
53  }
54 
55  subRegionBBox = FloatRect(useBBox.x() + subRegionBBox.x() * useBBox.width(),
56  useBBox.y() + subRegionBBox.y() * useBBox.height(),
57  subRegionBBox.width() * useBBox.width(),
58  subRegionBBox.height() * useBBox.height());
59  } else {
60  if (xBoundingBoxMode()) {
61  subRegionBBox.setX(useBBox.x() + subRegionBBox.x() * useBBox.width());
62  }
63 
64  if (yBoundingBoxMode()) {
65  subRegionBBox.setY(useBBox.y() + subRegionBBox.y() * useBBox.height());
66  }
67 
68  if (widthBoundingBoxMode()) {
69  subRegionBBox.setWidth(subRegionBBox.width() * useBBox.width());
70  }
71 
72  if (heightBoundingBoxMode()) {
73  subRegionBBox.setHeight(subRegionBBox.height() * useBBox.height());
74  }
75  }
76 
77  return subRegionBBox;
78 }
79 
80 FloatRect SVGFilterEffect::subRegion() const
81 {
82  return m_subRegion;
83 }
84 
85 void SVGFilterEffect::setSubRegion(const FloatRect &subRegion)
86 {
87  m_subRegion = subRegion;
88 }
89 
90 String SVGFilterEffect::in() const
91 {
92  return m_in;
93 }
94 
95 void SVGFilterEffect::setIn(const String &in)
96 {
97  m_in = in;
98 }
99 
100 String SVGFilterEffect::result() const
101 {
102  return m_result;
103 }
104 
105 void SVGFilterEffect::setResult(const String &result)
106 {
107  m_result = result;
108 }
109 
110 SVGResourceFilter *SVGFilterEffect::filter() const
111 {
112  return m_filter;
113 }
114 
115 void SVGFilterEffect::setFilter(SVGResourceFilter *filter)
116 {
117  m_filter = filter;
118 }
119 
120 TextStream &SVGFilterEffect::externalRepresentation(TextStream &ts) const
121 {
122  if (!in().isEmpty()) {
123  ts << "[in=\"" << in() << "\"]";
124  }
125  if (!result().isEmpty()) {
126  ts << " [result=\"" << result() << "\"]";
127  }
128  if (!subRegion().isEmpty()) {
129  ts << " [subregion=\"" << subRegion() << "\"]";
130  }
131  return ts;
132 }
133 
134 TextStream &operator<<(TextStream &ts, const SVGFilterEffect &e)
135 {
136  return e.externalRepresentation(ts);
137 }
138 
139 } // namespace WebCore
140 
141 #endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
QDataStream & operator<<(QDataStream &out, const KDateTime::Spec &spec)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Oct 16 2021 22:48:02 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.