KHTML
SVGFilterEffect.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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 }
00132
00133 #endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)