Changeset 44655 in webkit
- Timestamp:
- Jun 13, 2009 12:54:11 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 10 added
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r44647 r44655 1 2009-06-13 Dirk Schulze <krit@webkit.org> 2 3 Reviewed by Eric Seidel. 4 5 Added tests for the new subRgion-code on SVG filters. 6 7 * platform/mac/svg/filters: Added. 8 * platform/mac/svg/filters/subRegion-one-effect-expected.checksum: Added. 9 * platform/mac/svg/filters/subRegion-one-effect-expected.png: Added. 10 * platform/mac/svg/filters/subRegion-one-effect-expected.txt: Added. 11 * platform/mac/svg/filters/subRegion-two-effects-expected.checksum: Added. 12 * platform/mac/svg/filters/subRegion-two-effects-expected.png: Added. 13 * platform/mac/svg/filters/subRegion-two-effects-expected.txt: Added. 14 * svg/filters: Added. 15 * svg/filters/subRegion-one-effect.svg: Added. 16 * svg/filters/subRegion-two-effects.svg: Added. 17 1 18 2009-06-12 Jan Michael Alonzo <jmalonzo@webkit.org> 2 19 -
trunk/WebCore/ChangeLog
r44654 r44655 1 2009-06-13 Dirk Schulze <krit@webkit.org> 2 3 Reviewed by Eric Seidel. 4 5 Added subRegion calculation to SVG filter. Every filter effect is 6 clipped to the filter region (according to the spec). This makes 7 ImageBuffers for filter effects smaller and we just need to take 8 care about big filter regions. 9 SVGFEImage needed a correction, to avoid an ASSERT. The two filter 10 effects feOffset and feFlood help to test the new subRegion code. 11 12 Tests: svg/filters/subRegion-one-effect.svg 13 svg/filters/subRegion-two-effects.svg 14 15 * platform/graphics/filters/FEBlend.h: 16 (WebCore::FEBlend::uniteChildEffectSubregions): 17 * platform/graphics/filters/FEColorMatrix.h: 18 (WebCore::FEColorMatrix::uniteChildEffectSubregions): 19 * platform/graphics/filters/FEComponentTransfer.h: 20 (WebCore::FEComponentTransfer::uniteChildEffectSubregions): 21 * platform/graphics/filters/FEComposite.h: 22 (WebCore::FEComposite::uniteChildEffectSubregions): 23 * platform/graphics/filters/Filter.h: 24 (WebCore::Filter::setSourceImage): 25 (WebCore::Filter::sourceImage): 26 * platform/graphics/filters/FilterEffect.cpp: 27 (WebCore::FilterEffect::FilterEffect): 28 (WebCore::FilterEffect::calculateUnionOfChildEffectSubregions): 29 (WebCore::FilterEffect::calculateEffectRect): 30 * platform/graphics/filters/FilterEffect.h: 31 (WebCore::FilterEffect::setUnionOfChildEffectSubregions): 32 (WebCore::FilterEffect::unionOfChildEffectSubregions): 33 (WebCore::FilterEffect::hasX): 34 (WebCore::FilterEffect::setHasX): 35 (WebCore::FilterEffect::hasY): 36 (WebCore::FilterEffect::setHasY): 37 (WebCore::FilterEffect::hasWidth): 38 (WebCore::FilterEffect::setHasWidth): 39 (WebCore::FilterEffect::hasHeight): 40 (WebCore::FilterEffect::setHasHeight): 41 (WebCore::FilterEffect::setEffectBuffer): 42 (WebCore::FilterEffect::uniteChildEffectSubregions): 43 * platform/graphics/filters/SourceAlpha.h: 44 (WebCore::SourceAlpha::calculateEffectRect): 45 * platform/graphics/filters/SourceGraphic.cpp: 46 (WebCore::SourceGraphic::calculateEffectRect): 47 (WebCore::SourceGraphic::apply): 48 * platform/graphics/filters/SourceGraphic.h: 49 * rendering/SVGRenderSupport.cpp: 50 (WebCore::SVGRenderBase::prepareToRenderSVGContent): 51 (WebCore::SVGRenderBase::finishRenderSVGContent): 52 * svg/SVGFilterPrimitiveStandardAttributes.cpp: 53 (WebCore::SVGFilterPrimitiveStandardAttributes::setStandardAttributes): 54 * svg/graphics/SVGResourceFilter.cpp: 55 (WebCore::SVGResourceFilter::prepareFilter): 56 (WebCore::SVGResourceFilter::applyFilter): 57 * svg/graphics/SVGResourceFilter.h: 58 * svg/graphics/filters/SVGFEConvolveMatrix.h: 59 (WebCore::FEConvolveMatrix::uniteChildEffectSubregions): 60 * svg/graphics/filters/SVGFEDiffuseLighting.h: 61 (WebCore::FEDiffuseLighting::uniteChildEffectSubregions): 62 * svg/graphics/filters/SVGFEDisplacementMap.h: 63 (WebCore::FEDisplacementMap::uniteChildEffectSubregions): 64 * svg/graphics/filters/SVGFEFlood.cpp: 65 (WebCore::FEFlood::apply): 66 * svg/graphics/filters/SVGFEGaussianBlur.h: 67 (WebCore::FEGaussianBlur::uniteChildEffectSubregions): 68 * svg/graphics/filters/SVGFEImage.cpp: 69 (WebCore::FEImage::FEImage): 70 * svg/graphics/filters/SVGFEImage.h: 71 * svg/graphics/filters/SVGFEMerge.cpp: 72 (WebCore::FEMerge::uniteEffectRect): 73 * svg/graphics/filters/SVGFEMerge.h: 74 * svg/graphics/filters/SVGFEMorphology.h: 75 (WebCore::FEMorphology::uniteChildEffectSubregions): 76 * svg/graphics/filters/SVGFEOffset.cpp: 77 (WebCore::FEOffset::apply): 78 * svg/graphics/filters/SVGFEOffset.h: 79 (WebCore::FEOffset::uniteChildEffectSubregions): 80 * svg/graphics/filters/SVGFESpecularLighting.h: 81 (WebCore::FESpecularLighting::uniteEffectRect): 82 * svg/graphics/filters/SVGFETile.cpp: 83 (WebCore::FETile::uniteChildEffectSubregions): 84 * svg/graphics/filters/SVGFETile.h: 85 * svg/graphics/filters/SVGFilter.cpp: 86 (WebCore::SVGFilter::calculateEffectSubRegion): 87 * svg/graphics/filters/SVGFilter.h: 88 (WebCore::SVGFilter::effectBoundingBoxMode): 89 (WebCore::SVGFilter::filterRegion): 90 (WebCore::SVGFilter::sourceImageRect): 91 1 92 2009-06-13 Peter Kasting <pkasting@google.com> 2 93 -
trunk/WebCore/platform/graphics/filters/FEBlend.h
r44296 r44655 48 48 BlendModeType blendMode() const; 49 49 void setBlendMode(BlendModeType); 50 50 51 virtual FloatRect uniteChildEffectSubregions(Filter* filter) { return calculateUnionOfChildEffectSubregions(filter, m_in.get(), m_in2.get()); } 51 52 void apply(Filter*); 52 53 void dump(); -
trunk/WebCore/platform/graphics/filters/FEColorMatrix.h
r44296 r44655 48 48 const Vector<float>& values() const; 49 49 void setValues(const Vector<float>&); 50 50 51 virtual FloatRect uniteChildEffectSubregions(Filter* filter) { return calculateUnionOfChildEffectSubregions(filter, m_in.get()); } 51 52 void apply(Filter*); 52 53 void dump(); -
trunk/WebCore/platform/graphics/filters/FEComponentTransfer.h
r44296 r44655 79 79 ComponentTransferFunction alphaFunction() const; 80 80 void setAlphaFunction(const ComponentTransferFunction&); 81 81 82 virtual FloatRect uniteChildEffectSubregions(Filter* filter) { return calculateUnionOfChildEffectSubregions(filter, m_in.get()); } 82 83 void apply(Filter*); 83 84 void dump(); -
trunk/WebCore/platform/graphics/filters/FEComposite.h
r44296 r44655 60 60 float k4() const; 61 61 void setK4(float); 62 62 63 virtual FloatRect uniteChildEffectSubregions(Filter* filter) { return calculateUnionOfChildEffectSubregions(filter, m_in.get(), m_in2.get()); } 63 64 void apply(Filter*); 64 65 void dump(); -
trunk/WebCore/platform/graphics/filters/Filter.h
r44299 r44655 22 22 23 23 #if ENABLE(FILTERS) 24 #include "Image.h" 24 #include "FloatRect.h" 25 #include "ImageBuffer.h" 25 26 #include "StringHash.h" 26 27 … … 37 38 virtual ~Filter() { } 38 39 39 void setSourceImage(Pass RefPtr<Image> image) { m_image = image; }40 Image * sourceImage() { return m_image.get(); }40 void setSourceImage(PassOwnPtr<ImageBuffer> sourceImage) { m_sourceImage = sourceImage; } 41 ImageBuffer* sourceImage() { return m_sourceImage.get(); } 41 42 43 virtual FloatRect sourceImageRect() = 0; 44 virtual FloatRect filterRegion() = 0; 45 46 // SVG specific 42 47 virtual void calculateEffectSubRegion(FilterEffect*) = 0; 48 virtual bool effectBoundingBoxMode() = 0; 43 49 44 50 private: 45 RefPtr<Image> m_image;51 OwnPtr<ImageBuffer> m_sourceImage; 46 52 }; 47 53 -
trunk/WebCore/platform/graphics/filters/FilterEffect.cpp
r44253 r44655 30 30 , m_widthBBoxMode(false) 31 31 , m_heightBBoxMode(false) 32 , m_hasX(false) 33 , m_hasY(false) 34 , m_hasWidth(false) 35 , m_hasHeight(false) 32 36 { 33 37 } … … 35 39 FilterEffect::~FilterEffect() 36 40 { 41 } 42 43 FloatRect FilterEffect::calculateUnionOfChildEffectSubregions(Filter* filter, FilterEffect* in) 44 { 45 return in->calculateEffectRect(filter); 46 } 47 48 FloatRect FilterEffect::calculateUnionOfChildEffectSubregions(Filter* filter, FilterEffect* in, FilterEffect* in2) 49 { 50 FloatRect uniteEffectRect = in->calculateEffectRect(filter); 51 uniteEffectRect.unite(in2->calculateEffectRect(filter)); 52 return uniteEffectRect; 53 } 54 55 FloatRect FilterEffect::calculateEffectRect(Filter* filter) 56 { 57 setUnionOfChildEffectSubregions(uniteChildEffectSubregions(filter)); 58 filter->calculateEffectSubRegion(this); 59 return subRegion(); 37 60 } 38 61 -
trunk/WebCore/platform/graphics/filters/FilterEffect.h
r44296 r44655 28 28 #include "TextStream.h" 29 29 30 #include <wtf/PassOwnPtr.h> 30 31 #include <wtf/RefCounted.h> 31 32 #include <wtf/RefPtr.h> … … 49 50 void setHeightBoundingBoxMode(bool bboxMode) { m_heightBBoxMode = bboxMode; } 50 51 52 void setUnionOfChildEffectSubregions(const FloatRect& uniteRect) { m_unionOfChildEffectSubregions = uniteRect; } 53 FloatRect unionOfChildEffectSubregions() const { return m_unionOfChildEffectSubregions; } 54 51 55 FloatRect subRegion() const { return m_subRegion; } 52 56 void setSubRegion(const FloatRect& subRegion) { m_subRegion = subRegion; } 53 57 58 bool hasX() { return m_hasX; } 59 void setHasX(bool value) { m_hasX = value; } 60 61 bool hasY() { return m_hasY; } 62 void setHasY(bool value) { m_hasY = value; } 63 64 bool hasWidth() { return m_hasWidth; } 65 void setHasWidth(bool value) { m_hasWidth = value; } 66 67 bool hasHeight() { return m_hasHeight; } 68 void setHasHeight(bool value) { m_hasHeight = value; } 69 54 70 // The result is bounded by the size of the filter primitive to save resources 55 71 ImageBuffer* resultImage() { return m_effectBuffer.get(); } 56 void setEffectBuffer( ImageBuffer* effectBuffer) { m_effectBuffer.set(effectBuffer); }72 void setEffectBuffer(PassOwnPtr<ImageBuffer> effectBuffer) { m_effectBuffer = effectBuffer; } 57 73 74 FloatRect calculateUnionOfChildEffectSubregions(Filter*, FilterEffect*, FilterEffect*); 75 FloatRect calculateUnionOfChildEffectSubregions(Filter*, FilterEffect*); 76 77 virtual FloatRect uniteChildEffectSubregions(Filter* filter) { return filter->filterRegion(); } 78 virtual FloatRect calculateEffectRect(Filter*); 58 79 virtual void apply(Filter*) = 0; 59 80 virtual void dump() = 0; … … 70 91 bool m_heightBBoxMode : 1; 71 92 93 bool m_hasX : 1; 94 bool m_hasY : 1; 95 bool m_hasWidth : 1; 96 bool m_hasHeight : 1; 97 72 98 FloatRect m_subRegion; 99 FloatRect m_unionOfChildEffectSubregions; 73 100 74 101 mutable OwnPtr<ImageBuffer> m_effectBuffer; -
trunk/WebCore/platform/graphics/filters/SourceAlpha.h
r44296 r44655 35 35 static const AtomicString& effectName(); 36 36 37 virtual FloatRect calculateEffectRect(Filter* filter) { return filter->sourceImageRect(); } 37 38 void apply(Filter*); 38 39 void dump(); -
trunk/WebCore/platform/graphics/filters/SourceGraphic.cpp
r44296 r44655 42 42 } 43 43 44 void SourceGraphic::apply(Filter*)44 FloatRect SourceGraphic::calculateEffectRect(Filter* filter) 45 45 { 46 FloatRect clippedSourceRect = filter->sourceImageRect(); 47 if (filter->sourceImageRect().x() < filter->filterRegion().x()) 48 clippedSourceRect.setX(filter->filterRegion().x()); 49 if (filter->sourceImageRect().y() < filter->filterRegion().y()) 50 clippedSourceRect.setY(filter->filterRegion().y()); 51 setSubRegion(clippedSourceRect); 52 return filter->filterRegion(); 53 } 54 55 void SourceGraphic::apply(Filter* filter) 56 { 57 IntRect bufferRect = enclosingIntRect(subRegion()); 58 OwnPtr<ImageBuffer> filterGraphic(ImageBuffer::create(bufferRect.size(), false)); 59 60 if (!filterGraphic.get()) 61 return; 62 63 GraphicsContext* filterContext = filterGraphic->context(); 64 filterContext->drawImage(filter->sourceImage()->image(), IntPoint()); 65 66 setEffectBuffer(filterGraphic.release()); 46 67 } 47 68 -
trunk/WebCore/platform/graphics/filters/SourceGraphic.h
r44296 r44655 25 25 #include "FilterEffect.h" 26 26 27 #include "Filter.h" 27 28 #include "PlatformString.h" 28 #include "Filter.h"29 29 30 30 namespace WebCore { … … 36 36 static const AtomicString& effectName(); 37 37 38 virtual FloatRect calculateEffectRect(Filter*); 38 39 void apply(Filter*); 39 40 void dump(); -
trunk/WebCore/rendering/SVGRenderSupport.cpp
r44337 r44655 121 121 if (filter) { 122 122 filter->addClient(styledElement); 123 filter->prepareFilter(paintInfo.context, object ->objectBoundingBox());123 filter->prepareFilter(paintInfo.context, object); 124 124 } else if (!filterId.isEmpty()) 125 125 svgElement->document()->accessSVGExtensions()->addPendingResource(filterId, styledElement); … … 153 153 #if ENABLE(FILTERS) 154 154 if (filter) { 155 filter->applyFilter(paintInfo.context, object ->objectBoundingBox());155 filter->applyFilter(paintInfo.context, object); 156 156 paintInfo.context = savedContext; 157 157 } -
trunk/WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp
r44299 r44655 80 80 float _x, _y, _width, _height; 81 81 82 if (this->hasAttribute(SVGNames::xAttr)) 83 filterEffect->setHasX(true); 84 if (this->hasAttribute(SVGNames::yAttr)) 85 filterEffect->setHasY(true); 86 if (this->hasAttribute(SVGNames::widthAttr)) 87 filterEffect->setHasWidth(true); 88 if (this->hasAttribute(SVGNames::heightAttr)) 89 filterEffect->setHasHeight(true); 90 82 91 if (resourceFilter->effectBoundingBoxMode()) { 83 92 _x = x().valueAsPercentage(); -
trunk/WebCore/svg/graphics/SVGResourceFilter.cpp
r44309 r44655 67 67 } 68 68 69 void SVGResourceFilter::prepareFilter(GraphicsContext*& context, const FloatRect& itemRect)69 void SVGResourceFilter::prepareFilter(GraphicsContext*& context, const RenderObject* object) 70 70 { 71 m_itemBBox = object->objectBoundingBox(); 72 m_filterBBox = filterBBoxForItemBBox(m_itemBBox); 73 74 // clip sourceImage to filterRegion 75 FloatRect clippedSourceRect = m_itemBBox; 76 clippedSourceRect.intersect(m_filterBBox); 77 78 // prepare Filters 79 m_filter = SVGFilter::create(m_itemBBox, m_filterBBox, m_effectBBoxMode, m_filterBBoxMode); 80 81 FilterEffect* lastEffect = m_filterBuilder->lastEffect(); 82 if (lastEffect) 83 lastEffect->calculateEffectRect(m_filter.get()); 84 71 85 // Draw the content of the current element and it's childs to a imageBuffer to get the SourceGraphic. 72 // The size of the SourceGraphic must match the size of the element, the filter is aplied to.73 Int Size bufferSize = IntSize(itemRect.width(), itemRect.height());74 OwnPtr<ImageBuffer> sourceGraphic(ImageBuffer::create(buffer Size, false));86 // The size of the SourceGraphic is clipped to the size of the filterRegion. 87 IntRect bufferRect = enclosingIntRect(clippedSourceRect); 88 OwnPtr<ImageBuffer> sourceGraphic(ImageBuffer::create(bufferRect.size(), false)); 75 89 76 90 if (!sourceGraphic.get()) … … 78 92 79 93 GraphicsContext* sourceGraphicContext = sourceGraphic->context(); 80 sourceGraphicContext->translate(- itemRect.x(), -itemRect.y());81 sourceGraphicContext->clearRect(FloatRect( 0, 0, itemRect.width(), itemRect.height()));94 sourceGraphicContext->translate(-m_itemBBox.x(), -m_itemBBox.y()); 95 sourceGraphicContext->clearRect(FloatRect(FloatPoint(), m_itemBBox.size())); 82 96 m_sourceGraphicBuffer.set(sourceGraphic.release()); 83 97 m_savedContext = context; … … 86 100 } 87 101 88 void SVGResourceFilter::applyFilter(GraphicsContext*& context, const FloatRect& itemRect)102 void SVGResourceFilter::applyFilter(GraphicsContext*& context, const RenderObject*) 89 103 { 90 104 if (!m_savedContext) 91 105 return; 92 93 FloatRect filterRect = filterBBoxForItemBBox(itemRect);94 95 setFilterBoundingBox(filterRect);96 setItemBoundingBox(itemRect);97 106 98 107 context = m_savedContext; … … 101 110 FilterEffect* lastEffect = m_filterBuilder->lastEffect(); 102 111 103 if (lastEffect && !filterRect.isEmpty()) { 104 RefPtr<Filter> filter = SVGFilter::create(m_itemBBox, m_filterBBox, m_effectBBoxMode, m_filterBBoxMode); 105 filter->setSourceImage(m_sourceGraphicBuffer->image()); 106 lastEffect->apply(filter.get()); 107 108 context->clip(filterRect); 112 if (lastEffect && !m_filterBBox.isEmpty() && !lastEffect->subRegion().isEmpty()) { 113 m_filter->setSourceImage(m_sourceGraphicBuffer.release()); 114 lastEffect->apply(m_filter.get()); 109 115 110 116 if (lastEffect->resultImage()) 111 context->drawImage(lastEffect->resultImage()->image(), 112 lastEffect->subRegion()); 117 context->drawImage(lastEffect->resultImage()->image(), lastEffect->subRegion()); 113 118 } 114 119 -
trunk/WebCore/svg/graphics/SVGResourceFilter.h
r44309 r44655 30 30 #include "ImageBuffer.h" 31 31 #include "FloatRect.h" 32 #include "RenderObject.h" 32 33 #include "SVGFilterPrimitiveStandardAttributes.h" 33 34 … … 35 36 #include <wtf/PassOwnPtr.h> 36 37 #include <wtf/PassRefPtr.h> 38 #include <wtf/RefPtr.h> 37 39 38 40 namespace WebCore { … … 75 77 virtual TextStream& externalRepresentation(TextStream&) const; 76 78 77 void prepareFilter(GraphicsContext*&, const FloatRect&);78 void applyFilter(GraphicsContext*&, const FloatRect&);79 void prepareFilter(GraphicsContext*&, const RenderObject*); 80 void applyFilter(GraphicsContext*&, const RenderObject*); 79 81 80 82 void addFilterEffect(SVGFilterPrimitiveStandardAttributes*, PassRefPtr<FilterEffect>); … … 98 100 GraphicsContext* m_savedContext; 99 101 OwnPtr<ImageBuffer> m_sourceGraphicBuffer; 102 RefPtr<Filter> m_filter; 100 103 }; 101 104 -
trunk/WebCore/svg/graphics/filters/SVGFEConvolveMatrix.h
r44296 r44655 69 69 void setPreserveAlpha(bool); 70 70 71 virtual FloatRect uniteChildEffectSubregions(Filter* filter) { return calculateUnionOfChildEffectSubregions(filter, m_in.get(), m_in2.get()); } 71 72 void apply(Filter*); 72 73 void dump(); -
trunk/WebCore/svg/graphics/filters/SVGFEDiffuseLighting.h
r44296 r44655 56 56 void setLightSource(LightSource*); 57 57 58 virtual FloatRect uniteChildEffectSubregions(Filter* filter) { return calculateUnionOfChildEffectSubregions(filter, m_in.get()); } 58 59 void apply(Filter*); 59 60 void dump(); -
trunk/WebCore/svg/graphics/filters/SVGFEDisplacementMap.h
r44296 r44655 52 52 void setScale(float scale); 53 53 54 virtual FloatRect uniteChildEffectSubregions(Filter* filter) { return calculateUnionOfChildEffectSubregions(filter, m_in.get(), m_in2.get()); } 54 55 void apply(Filter*); 55 56 void dump(); -
trunk/WebCore/svg/graphics/filters/SVGFEFlood.cpp
r44337 r44655 3 3 2004, 2005 Rob Buis <buis@kde.org> 4 4 2005 Eric Seidel <eric@webkit.org> 5 2009 Dirk Schulze <krit@webkit.org> 5 6 6 7 This library is free software; you can redistribute it and/or … … 24 25 #if ENABLE(SVG) && ENABLE(FILTERS) 25 26 #include "SVGFEFlood.h" 27 26 28 #include "Filter.h" 29 #include "GraphicsContext.h" 27 30 #include "SVGRenderTreeAsText.h" 28 31 … … 64 67 void FEFlood::apply(Filter*) 65 68 { 69 IntRect bufferRect = enclosingIntRect(subRegion()); 70 OwnPtr<ImageBuffer> filterGraphic(ImageBuffer::create(bufferRect.size(), false)); 71 72 if (!filterGraphic) 73 return; 74 75 Color color = colorWithOverrideAlpha(floodColor().rgb(), floodOpacity()); 76 GraphicsContext* filterContext = filterGraphic->context(); 77 filterContext->fillRect(FloatRect(FloatPoint(), subRegion().size()), color); 78 79 setEffectBuffer(filterGraphic.release()); 66 80 } 67 81 -
trunk/WebCore/svg/graphics/filters/SVGFEGaussianBlur.h
r44296 r44655 39 39 void setStdDeviationY(float); 40 40 41 virtual FloatRect uniteChildEffectSubregions(Filter* filter) { return calculateUnionOfChildEffectSubregions(filter, m_in.get()); } 41 42 void apply(Filter*); 42 43 void dump(); -
trunk/WebCore/svg/graphics/filters/SVGFEImage.cpp
r44296 r44655 33 33 , m_cachedImage(cachedImage) 34 34 { 35 m_cachedImage->addClient(this); 35 36 } 36 37 -
trunk/WebCore/svg/graphics/filters/SVGFEImage.h
r44296 r44655 42 42 CachedImage* cachedImage() const; 43 43 void setCachedImage(CachedImage*); 44 44 45 45 void apply(Filter*); 46 46 void dump(); -
trunk/WebCore/svg/graphics/filters/SVGFEMerge.cpp
r44296 r44655 50 50 } 51 51 52 FloatRect FEMerge::uniteEffectRect(Filter* filter) 53 { 54 if (m_mergeInputs.isEmpty()) 55 return FloatRect(); 56 57 FloatRect uniteEffectRect = m_mergeInputs[0]->calculateEffectRect(filter); 58 59 for (unsigned i = 1; i < m_mergeInputs.size(); i++) 60 uniteEffectRect.unite(m_mergeInputs[i]->calculateEffectRect(filter)); 61 62 return uniteEffectRect; 63 } 64 52 65 void FEMerge::apply(Filter*) 53 66 { -
trunk/WebCore/svg/graphics/filters/SVGFEMerge.h
r44296 r44655 36 36 const Vector<FilterEffect*>& mergeInputs() const; 37 37 void setMergeInputs(const Vector<FilterEffect*>& mergeInputs); 38 38 39 virtual FloatRect uniteEffectRect(Filter*); 39 40 void apply(Filter*); 40 41 void dump(); -
trunk/WebCore/svg/graphics/filters/SVGFEMorphology.h
r44296 r44655 47 47 void setRadiusY(float); 48 48 49 virtual FloatRect uniteChildEffectSubregions(Filter* filter) { return calculateUnionOfChildEffectSubregions(filter, m_in.get()); } 49 50 void apply(Filter*); 50 51 void dump(); -
trunk/WebCore/svg/graphics/filters/SVGFEOffset.cpp
r44296 r44655 3 3 2004, 2005 Rob Buis <buis@kde.org> 4 4 2005 Eric Seidel <eric@webkit.org> 5 2009 Dirk Schulze <krit@webkit.org> 5 6 6 7 This library is free software; you can redistribute it and/or … … 24 25 #if ENABLE(SVG) && ENABLE(FILTERS) 25 26 #include "SVGFEOffset.h" 27 28 #include "Filter.h" 29 #include "GraphicsContext.h" 26 30 #include "SVGRenderTreeAsText.h" 27 #include "Filter.h"28 31 29 32 namespace WebCore { … … 62 65 } 63 66 64 void FEOffset::apply(Filter* )67 void FEOffset::apply(Filter* filter) 65 68 { 69 m_in->apply(filter); 70 if (!m_in->resultImage()) 71 return; 72 73 IntRect bufferRect = enclosingIntRect(subRegion()); 74 OwnPtr<ImageBuffer> filterGraphic(ImageBuffer::create(bufferRect.size(), false)); 75 76 if (!filterGraphic) 77 return; 78 79 FloatRect dstRect = FloatRect(dx() + m_in->subRegion().x() - subRegion().x(), 80 dy() + m_in->subRegion().y() - subRegion().y(), 81 m_in->subRegion().width(), 82 m_in->subRegion().height()); 83 84 GraphicsContext* filterContext = filterGraphic->context(); 85 filterContext->drawImage(m_in->resultImage()->image(), dstRect); 86 setEffectBuffer(filterGraphic.release()); 66 87 } 67 88 -
trunk/WebCore/svg/graphics/filters/SVGFEOffset.h
r44296 r44655 39 39 void setDy(float); 40 40 41 virtual FloatRect uniteChildEffectSubregions(Filter* filter) { return calculateUnionOfChildEffectSubregions(filter, m_in.get()); } 41 42 void apply(Filter*); 42 43 void dump(); -
trunk/WebCore/svg/graphics/filters/SVGFESpecularLighting.h
r44296 r44655 58 58 void setLightSource(LightSource*); 59 59 60 virtual FloatRect uniteEffectRect(Filter* filter) { return calculateUnionOfChildEffectSubregions(filter, m_in.get()); } 60 61 void apply(Filter*); 61 62 void dump(); -
trunk/WebCore/svg/graphics/filters/SVGFETile.cpp
r44296 r44655 22 22 #if ENABLE(SVG) && ENABLE(FILTERS) 23 23 #include "SVGFETile.h" 24 25 #include "Filter.h" 24 26 #include "SVGRenderTreeAsText.h" 25 #include "Filter.h"26 27 27 28 namespace WebCore { … … 36 37 { 37 38 return adoptRef(new FETile(in)); 39 } 40 41 FloatRect FETile::uniteChildEffectSubregions(Filter* filter) 42 { 43 m_in->calculateEffectRect(filter); 44 return filter->filterRegion(); 38 45 } 39 46 -
trunk/WebCore/svg/graphics/filters/SVGFETile.h
r44296 r44655 33 33 static PassRefPtr<FETile> create(FilterEffect*); 34 34 35 virtual FloatRect uniteChildEffectSubregions(Filter*); 35 36 void apply(Filter*); 36 37 void dump(); -
trunk/WebCore/svg/graphics/filters/SVGFilter.cpp
r44296 r44655 34 34 } 35 35 36 void SVGFilter::calculateEffectSubRegion(FilterEffect* )36 void SVGFilter::calculateEffectSubRegion(FilterEffect* effect) 37 37 { 38 FloatRect subRegionBBox = effect->subRegion(); 39 FloatRect useBBox = effect->unionOfChildEffectSubregions(); 40 41 FloatRect newSubRegion = subRegionBBox; 42 43 if (m_effectBBoxMode) { 44 newSubRegion = useBBox; 45 46 if (effect->hasX()) 47 newSubRegion.setX(m_itemBox.x() + subRegionBBox.x() * m_itemBox.width()); 48 49 if (effect->hasY()) 50 newSubRegion.setY(m_itemBox.y() + subRegionBBox.y() * m_itemBox.height()); 51 52 if (effect->hasWidth()) 53 newSubRegion.setWidth(subRegionBBox.width() * m_itemBox.width()); 54 55 if (effect->hasHeight()) 56 newSubRegion.setHeight(subRegionBBox.height() * m_itemBox.height()); 57 } else { 58 if (effect->xBoundingBoxMode()) 59 newSubRegion.setX(useBBox.x() + subRegionBBox.x() * useBBox.width()); 60 61 if (effect->yBoundingBoxMode()) 62 newSubRegion.setY(useBBox.y() + subRegionBBox.y() * useBBox.height()); 63 64 if (effect->widthBoundingBoxMode()) 65 newSubRegion.setWidth(subRegionBBox.width() * useBBox.width()); 66 67 if (effect->heightBoundingBoxMode()) 68 newSubRegion.setHeight(subRegionBBox.height() * useBBox.height()); 69 } 70 71 // clip every filter effect to the filter region 72 newSubRegion.intersect(m_filterRect); 73 74 effect->setSubRegion(newSubRegion); 38 75 } 39 76 -
trunk/WebCore/svg/graphics/filters/SVGFilter.h
r44296 r44655 36 36 static PassRefPtr<SVGFilter> create(const FloatRect&, const FloatRect&, bool, bool); 37 37 38 bool effectBoundingBoxMode() { return m_effectBBoxMode; } 39 40 FloatRect filterRegion() { return m_filterRect; } 41 FloatRect sourceImageRect() { return m_itemBox; } 38 42 void calculateEffectSubRegion(FilterEffect*); 39 43
Note: See TracChangeset
for help on using the changeset viewer.