Changeset 69416 in webkit


Ignore:
Timestamp:
Oct 8, 2010 12:40:42 PM (14 years ago)
Author:
krit@webkit.org
Message:

2010-10-08 Dirk Schulze <krit@webkit.org>

Reviewed by Nikolas Zimmermann.

SVG feImage needs absolute subregion for preserveAspectRatio
https://bugs.webkit.org/show_bug.cgi?id=47409

PreserverAspectRatio needs the subregion in absolute coordinates to determine
the destination position and size of the input image. The maxEffectRect() already
stores the absolute subregion, but clipped to the filter region.

Test: svg/W3C-SVG-1.1se/filters-image-03-f.svg

  • platform/graphics/filters/FETile.cpp: (WebCore::FETile::apply):
  • platform/graphics/filters/FilterEffect.h: Added enum to differentate sourece inputs, feTile and feImage. (WebCore::FilterEffect::filterEffectType):
  • platform/graphics/filters/SourceAlpha.h: Make use of the new enum in FilterEffect (WebCore::SourceAlpha::filterEffectType):
  • platform/graphics/filters/SourceGraphic.h: Ditto. (WebCore::SourceGraphic::filterEffectType):
  • svg/graphics/filters/SVGFEImage.cpp: Take the absolute subregion to determine the destination rect for input image. (WebCore::FEImage::apply):
  • svg/graphics/filters/SVGFEImage.h: Ditto. (WebCore::FEImage::setAbsoluteSubregion): (WebCore::FEImage::filterEffectType):
  • svg/graphics/filters/SVGFilter.cpp: Give over subregion in absolute coordinates to feImage. Just feImage makes use of it. (WebCore::SVGFilter::determineFilterPrimitiveSubregion):

2010-10-08 Dirk Schulze <krit@webkit.org>

Reviewed by Nikolas Zimmermann.

SVG feImage needs absolute subregion for preserveAspectRatio
https://bugs.webkit.org/show_bug.cgi?id=47409

Adapted test form the new SVG 1.1 se test suite to check the correct behavior of feImage.
The subregion in absolute coordinates is a FloatRect instead of an IntRect. This
sharpens the result of svg/webarchive/svg-feimage-subresources.

  • platform/mac/svg/W3C-SVG-1.1-SE/filters-image-03-f-expected.checksum: Added.
  • platform/mac/svg/W3C-SVG-1.1-SE/filters-image-03-f-expected.png: Added.
  • platform/mac/svg/W3C-SVG-1.1-SE/filters-image-03-f-expected.txt: Added.
  • platform/mac/svg/webarchive/svg-feimage-subresources-expected.checksum:
  • platform/mac/svg/webarchive/svg-feimage-subresources-expected.png:
  • svg/W3C-SVG-1.1-SE/filters-image-03-f.svg: Added.
Location:
trunk
Files:
4 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r69413 r69416  
     12010-10-08  Dirk Schulze  <krit@webkit.org>
     2
     3        Reviewed by Nikolas Zimmermann.
     4
     5        SVG feImage needs absolute subregion for preserveAspectRatio
     6        https://bugs.webkit.org/show_bug.cgi?id=47409
     7
     8        Adapted test form the new SVG 1.1 se test suite to check the correct behavior of feImage.
     9        The subregion in absolute coordinates is a FloatRect instead of an IntRect. This
     10        sharpens the result of svg/webarchive/svg-feimage-subresources.
     11
     12        * platform/mac/svg/W3C-SVG-1.1-SE/filters-image-03-f-expected.checksum: Added.
     13        * platform/mac/svg/W3C-SVG-1.1-SE/filters-image-03-f-expected.png: Added.
     14        * platform/mac/svg/W3C-SVG-1.1-SE/filters-image-03-f-expected.txt: Added.
     15        * platform/mac/svg/webarchive/svg-feimage-subresources-expected.checksum:
     16        * platform/mac/svg/webarchive/svg-feimage-subresources-expected.png:
     17        * svg/W3C-SVG-1.1-SE/filters-image-03-f.svg: Added.
     18
    1192010-10-08  Nikolas Zimmermann  <nzimmermann@rim.com>
    220
  • trunk/LayoutTests/platform/mac/svg/webarchive/svg-feimage-subresources-expected.checksum

    r69292 r69416  
    1 f080f575091da0c119e750b02e74b090
     1d645c06189914812437235a8936bc83d
  • trunk/WebCore/ChangeLog

    r69413 r69416  
     12010-10-08  Dirk Schulze  <krit@webkit.org>
     2
     3        Reviewed by Nikolas Zimmermann.
     4
     5        SVG feImage needs absolute subregion for preserveAspectRatio
     6        https://bugs.webkit.org/show_bug.cgi?id=47409
     7
     8        PreserverAspectRatio needs the subregion in absolute coordinates to determine
     9        the destination position and size of the input image. The maxEffectRect() already
     10        stores the absolute subregion, but clipped to the filter region.
     11
     12        Test: svg/W3C-SVG-1.1se/filters-image-03-f.svg
     13
     14        * platform/graphics/filters/FETile.cpp:
     15        (WebCore::FETile::apply):
     16        * platform/graphics/filters/FilterEffect.h: Added enum to differentate sourece inputs, feTile and feImage.
     17        (WebCore::FilterEffect::filterEffectType):
     18        * platform/graphics/filters/SourceAlpha.h: Make use of the new enum in FilterEffect
     19        (WebCore::SourceAlpha::filterEffectType):
     20        * platform/graphics/filters/SourceGraphic.h: Ditto.
     21        (WebCore::SourceGraphic::filterEffectType):
     22        * svg/graphics/filters/SVGFEImage.cpp: Take the absolute subregion to determine the destination rect for input image.
     23        (WebCore::FEImage::apply):
     24        * svg/graphics/filters/SVGFEImage.h: Ditto.
     25        (WebCore::FEImage::setAbsoluteSubregion):
     26        (WebCore::FEImage::filterEffectType):
     27        * svg/graphics/filters/SVGFilter.cpp: Give over subregion in absolute coordinates to feImage. Just feImage makes use of it.
     28        (WebCore::SVGFilter::determineFilterPrimitiveSubregion):
     29
    1302010-10-08  Nikolas Zimmermann  <nzimmermann@rim.com>
    231
  • trunk/WebCore/platform/graphics/filters/FETile.cpp

    r69255 r69416  
    7070    FloatPoint inMaxEffectLocation = tileRect.location();
    7171    FloatPoint maxEffectLocation = maxEffectRect().location();
    72     if (in->isSourceInput()) {
     72    if (in->filterEffectType() == FilterEffectTypeSourceInput) {
    7373        tileRect = filter->filterRegion();
    7474        tileRect.scale(filter->filterResolution().width(), filter->filterResolution().height());
  • trunk/WebCore/platform/graphics/filters/FilterEffect.h

    r69181 r69416  
    4040typedef Vector<RefPtr<FilterEffect> > FilterEffectVector;
    4141
     42enum FilterEffectType {
     43    FilterEffectTypeUnknown,
     44    FilterEffectTypeImage,
     45    FilterEffectTypeTile,
     46    FilterEffectTypeSourceInput
     47};
     48
    4249class FilterEffect : public RefCounted<FilterEffect> {
    4350public:
     
    6572    IntRect absolutePaintRect() const { return m_absolutePaintRect; }
    6673    void setAbsolutePaintRect(const IntRect& absolutePaintRect) { m_absolutePaintRect = absolutePaintRect; }
    67    
     74
    6875    IntRect maxEffectRect() const { return m_maxEffectRect; }
    6976    void setMaxEffectRect(const IntRect& maxEffectRect) { m_maxEffectRect = maxEffectRect; }
     
    7380
    7481    virtual void determineAbsolutePaintRect(Filter*);
    75    
    76     virtual bool isSourceInput() const { return false; }
     82
     83    virtual FilterEffectType filterEffectType() const { return FilterEffectTypeUnknown; }
    7784
    7885    virtual TextStream& externalRepresentation(TextStream&, int indention = 0) const;
  • trunk/WebCore/platform/graphics/filters/SourceAlpha.h

    r69181 r69416  
    4040    virtual void determineAbsolutePaintRect(Filter*);
    4141
    42     virtual bool isSourceInput() const { return true; }
     42    virtual FilterEffectType filterEffectType() const { return FilterEffectTypeSourceInput; }
    4343
    4444    virtual TextStream& externalRepresentation(TextStream&, int indention) const;
  • trunk/WebCore/platform/graphics/filters/SourceGraphic.h

    r69181 r69416  
    4141    virtual void determineAbsolutePaintRect(Filter*);
    4242
    43     virtual bool isSourceInput() const { return true; }
     43    virtual FilterEffectType filterEffectType() const { return FilterEffectTypeSourceInput; }
    4444
    4545    virtual TextStream& externalRepresentation(TextStream&, int indention) const;
  • trunk/WebCore/svg/graphics/filters/SVGFEImage.cpp

    r69181 r69416  
    5555
    5656    FloatRect srcRect(FloatPoint(), m_image->size());
    57     FloatRect destRect(FloatPoint(), absolutePaintRect().size());
     57    FloatRect destRect(m_absoluteSubregion);
    5858
    5959    m_preserveAspectRatio.transformRect(destRect, srcRect);
     60    destRect.move(-m_absoluteSubregion.x(), -m_absoluteSubregion.y());
    6061
    6162    filterContext->drawImage(m_image.get(), DeviceColorSpace, destRect, srcRect);
  • trunk/WebCore/svg/graphics/filters/SVGFEImage.h

    r69181 r69416  
    3434    static PassRefPtr<FEImage> create(RefPtr<Image>, const SVGPreserveAspectRatio&);
    3535
     36    void setAbsoluteSubregion(const FloatRect& absoluteSubregion) { m_absoluteSubregion = absoluteSubregion; }
     37
    3638    virtual void apply(Filter*);
    3739    virtual void dump();
    3840
    3941    virtual void determineAbsolutePaintRect(Filter*) { setAbsolutePaintRect(maxEffectRect()); }
     42
     43    virtual FilterEffectType filterEffectType() const { return FilterEffectTypeImage; }
    4044
    4145    virtual TextStream& externalRepresentation(TextStream&, int indention) const;
     
    4650    RefPtr<Image> m_image;
    4751    SVGPreserveAspectRatio m_preserveAspectRatio;
     52    FloatRect m_absoluteSubregion;
    4853};
    4954
  • trunk/WebCore/svg/graphics/filters/SVGFilter.cpp

    r69181 r69416  
    2323#if ENABLE(SVG) && ENABLE(FILTERS)
    2424#include "SVGFilter.h"
     25
     26#include "SVGFEImage.h"
    2527
    2628namespace WebCore {
     
    7072    }
    7173
    72     // clip every filter effect to the filter region
    73     newSubRegion.intersect(m_filterRegion);
    74 
    7574    effect->setFilterPrimitiveSubregion(newSubRegion);
    7675    // TODO: Everything above should be moved to a first phase of layout in RenderSVGResourceFilterPrimitive.
     
    8079    newSubRegion = m_absoluteTransform.mapRect(newSubRegion);
    8180    newSubRegion.scale(filterResolution().width(), filterResolution().height());
     81
     82    // FEImage needs the unclipped subregion in absolute coordinates to determine the correct
     83    // destination rect in combination with preserveAspectRatio.
     84    if (effect->filterEffectType() == FilterEffectTypeImage) {
     85        FEImage* imageEffect = static_cast<FEImage*>(effect);
     86        imageEffect->setAbsoluteSubregion(newSubRegion);
     87    }
     88
     89    // Clip every filter effect to the filter region.
     90    FloatRect absoluteScaledFilterRegion = m_absoluteFilterRegion;
     91    absoluteScaledFilterRegion.scale(filterResolution().width(), filterResolution().height());
     92    newSubRegion.intersect(absoluteScaledFilterRegion);
     93
    8294    effect->setMaxEffectRect(enclosingIntRect(newSubRegion));
    83     if (!effect->isSourceInput())
     95    if (effect->filterEffectType() != FilterEffectTypeSourceInput)
    8496        m_maxImageSize = m_maxImageSize.expandedTo(newSubRegion.size());
    8597}
Note: See TracChangeset for help on using the changeset viewer.