KHTML
SVGFilterEffect.cpp
Go to the documentation of this file.
00001 /* 00002 Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> 00003 2004, 2005 Rob Buis <buis@kde.org> 00004 2005 Eric Seidel <eric@webkit.org> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 aint with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. 00020 */ 00021 00022 #include "config.h" 00023 00024 #if ENABLE(SVG) && ENABLE(SVG_FILTERS) 00025 #include "SVGFilterEffect.h" 00026 00027 #include "SVGRenderTreeAsText.h" 00028 #include "SVGResourceFilter.h" 00029 00030 namespace WebCore { 00031 00032 SVGFilterEffect::SVGFilterEffect(SVGResourceFilter* filter) 00033 : m_filter(filter) 00034 , m_xBBoxMode(false) 00035 , m_yBBoxMode(false) 00036 , m_widthBBoxMode(false) 00037 , m_heightBBoxMode(false) 00038 { 00039 } 00040 00041 FloatRect SVGFilterEffect::primitiveBBoxForFilterBBox(const FloatRect& filterBBox, const FloatRect& itemBBox) const 00042 { 00043 FloatRect subRegionBBox = subRegion(); 00044 FloatRect useBBox = filterBBox; 00045 00046 ASSERT(m_filter); 00047 if (!m_filter) 00048 return FloatRect(); 00049 00050 if (m_filter->effectBoundingBoxMode()) { 00051 if (!m_filter->filterBoundingBoxMode()) 00052 useBBox = itemBBox; 00053 00054 subRegionBBox = FloatRect(useBBox.x() + subRegionBBox.x() * useBBox.width(), 00055 useBBox.y() + subRegionBBox.y() * useBBox.height(), 00056 subRegionBBox.width() * useBBox.width(), 00057 subRegionBBox.height() * useBBox.height()); 00058 } else { 00059 if (xBoundingBoxMode()) 00060 subRegionBBox.setX(useBBox.x() + subRegionBBox.x() * useBBox.width()); 00061 00062 if (yBoundingBoxMode()) 00063 subRegionBBox.setY(useBBox.y() + subRegionBBox.y() * useBBox.height()); 00064 00065 if (widthBoundingBoxMode()) 00066 subRegionBBox.setWidth(subRegionBBox.width() * useBBox.width()); 00067 00068 if (heightBoundingBoxMode()) 00069 subRegionBBox.setHeight(subRegionBBox.height() * useBBox.height()); 00070 } 00071 00072 return subRegionBBox; 00073 } 00074 00075 FloatRect SVGFilterEffect::subRegion() const 00076 { 00077 return m_subRegion; 00078 } 00079 00080 void SVGFilterEffect::setSubRegion(const FloatRect& subRegion) 00081 { 00082 m_subRegion = subRegion; 00083 } 00084 00085 String SVGFilterEffect::in() const 00086 { 00087 return m_in; 00088 } 00089 00090 void SVGFilterEffect::setIn(const String& in) 00091 { 00092 m_in = in; 00093 } 00094 00095 String SVGFilterEffect::result() const 00096 { 00097 return m_result; 00098 } 00099 00100 void SVGFilterEffect::setResult(const String& result) 00101 { 00102 m_result = result; 00103 } 00104 00105 SVGResourceFilter* SVGFilterEffect::filter() const 00106 { 00107 return m_filter; 00108 } 00109 00110 void SVGFilterEffect::setFilter(SVGResourceFilter* filter) 00111 { 00112 m_filter = filter; 00113 } 00114 00115 TextStream& SVGFilterEffect::externalRepresentation(TextStream& ts) const 00116 { 00117 if (!in().isEmpty()) 00118 ts << "[in=\"" << in() << "\"]"; 00119 if (!result().isEmpty()) 00120 ts << " [result=\"" << result() << "\"]"; 00121 if (!subRegion().isEmpty()) 00122 ts << " [subregion=\"" << subRegion() << "\"]"; 00123 return ts; 00124 } 00125 00126 TextStream& operator<<(TextStream& ts, const SVGFilterEffect& e) 00127 { 00128 return e.externalRepresentation(ts); 00129 } 00130 00131 } // namespace WebCore 00132 00133 #endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
KDE 4.6 API Reference