24 #if ENABLE(SVG) && ENABLE(SVG_FILTERS)
27 #include "SVGRenderTreeAsText.h"
32 SVGResourceFilter::SVGResourceFilter()
33 : m_platformData(createPlatformData())
34 , m_filterBBoxMode(false)
35 , m_effectBBoxMode(false)
41 void SVGResourceFilter::clearEffects()
46 void SVGResourceFilter::addFilterEffect(SVGFilterEffect* effect)
51 ASSERT(effect->filter() ==
this);
52 m_effects.append(effect);
56 FloatRect SVGResourceFilter::filterBBoxForItemBBox(
const FloatRect& itemBBox)
const
58 FloatRect filterBBox = filterRect();
63 if (!effectBoundingBoxMode()) {
64 xOffset = itemBBox.x();
65 yOffset = itemBBox.y();
68 if (filterBoundingBoxMode()) {
69 filterBBox = FloatRect(xOffset + filterBBox.x() * itemBBox.width(),
70 yOffset + filterBBox.y() * itemBBox.height(),
71 filterBBox.width() * itemBBox.width(),
72 filterBBox.height() * itemBBox.height());
74 if (xBoundingBoxMode())
75 filterBBox.setX(xOffset + filterBBox.x());
77 if (yBoundingBoxMode())
78 filterBBox.setY(yOffset + filterBBox.y());
84 TextStream& SVGResourceFilter::externalRepresentation(TextStream& ts)
const
86 ts <<
"[type=FILTER] ";
88 FloatRect bbox = filterRect();
89 static FloatRect defaultFilterRect(0, 0, 1, 1);
91 if (!filterBoundingBoxMode() || bbox != defaultFilterRect) {
92 ts <<
" [bounding box=";
93 if (filterBoundingBoxMode()) {
95 ts <<
"at (" << bbox.x() <<
"%," << bbox.y() <<
"%) size " << bbox.width() <<
"%x" << bbox.height() <<
"%";
101 if (!filterBoundingBoxMode())
102 ts <<
" [bounding box mode=" << filterBoundingBoxMode() <<
"]";
103 if (effectBoundingBoxMode())
104 ts <<
" [effect bounding box mode=" << effectBoundingBoxMode() <<
"]";
105 if (m_effects.size() > 0)
106 ts <<
" [effects=" << m_effects <<
"]";
111 SVGResourceFilter* getFilterById(Document* document,
const AtomicString&
id)
113 SVGResource* resource = getResourceById(document,
id);
114 if (resource && resource->isFilter())
115 return static_cast<SVGResourceFilter*>(resource);
123 #endif // ENABLE(SVG)