Changeset 44840 in webkit


Ignore:
Timestamp:
Jun 18, 2009 10:00:30 PM (15 years ago)
Author:
krit@webkit.org
Message:

2009-06-18 Dirk Schulze <krit@webkit.org>

Reviewed by Oliver Hunt.

feTile implementation missing
https://bugs.webkit.org/show_bug.cgi?id=26419

Implementation of feTile, a pattern effect for SVG filters. It was
necessary to modify FilterEffect since source inputs need a secial
logic and we have to identify if an effect is a source input.

Tests: svg/batik/filters/feTile.svg

svg/filters/feTile.svg

  • platform/graphics/filters/FilterEffect.h: (WebCore::FilterEffect::isSourceInput):
  • platform/graphics/filters/SourceAlpha.h: (WebCore::SourceAlpha::isSourceInput):
  • platform/graphics/filters/SourceGraphic.h: (WebCore::SourceGraphic::isSourceInput):
  • svg/graphics/filters/SVGFETile.cpp: (WebCore::FETile::apply):

Reviewed by Oliver Hunt.

Added a test of batik and a own one to check behavior of the
new feTile effect in SVG.

  • platform/mac/svg/batik/filters/feTile-expected.checksum: Added.
  • platform/mac/svg/batik/filters/feTile-expected.png: Added.
  • platform/mac/svg/batik/filters/feTile-expected.txt: Added.
  • platform/mac/svg/filters/feTile-expected.checksum: Added.
  • platform/mac/svg/filters/feTile-expected.png: Added.
  • platform/mac/svg/filters/feTile-expected.txt: Added.
  • svg/batik/filters/feTile.svg: Added.
  • svg/filters/feTile.svg: Added.
Location:
trunk
Files:
8 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r44839 r44840  
     12009-06-18  Dirk Schulze  <krit@webkit.org>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        Added a test of batik and a own one to check behavior of the
     6        new feTile effect in SVG.
     7
     8        * platform/mac/svg/batik/filters/feTile-expected.checksum: Added.
     9        * platform/mac/svg/batik/filters/feTile-expected.png: Added.
     10        * platform/mac/svg/batik/filters/feTile-expected.txt: Added.
     11        * platform/mac/svg/filters/feTile-expected.checksum: Added.
     12        * platform/mac/svg/filters/feTile-expected.png: Added.
     13        * platform/mac/svg/filters/feTile-expected.txt: Added.
     14        * svg/batik/filters/feTile.svg: Added.
     15        * svg/filters/feTile.svg: Added.
     16
    1172009-06-18  Dirk Schulze  <krit@webkit.org>
    218
  • trunk/WebCore/ChangeLog

    r44839 r44840  
     12009-06-18  Dirk Schulze  <krit@webkit.org>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        feTile implementation missing
     6        [https://bugs.webkit.org/show_bug.cgi?id=26419]
     7
     8        Implementation of feTile, a pattern effect for SVG filters. It was
     9        necessary to modify FilterEffect since source inputs need a secial
     10        logic and we have to identify if an effect is a source input.
     11
     12        Tests: svg/batik/filters/feTile.svg
     13               svg/filters/feTile.svg
     14
     15        * platform/graphics/filters/FilterEffect.h:
     16        (WebCore::FilterEffect::isSourceInput):
     17        * platform/graphics/filters/SourceAlpha.h:
     18        (WebCore::SourceAlpha::isSourceInput):
     19        * platform/graphics/filters/SourceGraphic.h:
     20        (WebCore::SourceGraphic::isSourceInput):
     21        * svg/graphics/filters/SVGFETile.cpp:
     22        (WebCore::FETile::apply):
     23
    1242009-06-18  Dirk Schulze  <krit@webkit.org>
    225
  • trunk/WebCore/platform/graphics/filters/FilterEffect.h

    r44810 r44840  
    8484        virtual void dump() = 0;
    8585
     86        virtual bool isSourceInput() { return false; }
     87
    8688        virtual TextStream& externalRepresentation(TextStream&) const;
    8789    protected:
  • trunk/WebCore/platform/graphics/filters/SourceAlpha.h

    r44655 r44840  
    3535        static const AtomicString& effectName();
    3636
     37        virtual bool isSourceInput() { return true; }
    3738        virtual FloatRect calculateEffectRect(Filter* filter) { return filter->sourceImageRect(); }
    3839        void apply(Filter*);
  • trunk/WebCore/platform/graphics/filters/SourceGraphic.h

    r44655 r44840  
    3636        static const AtomicString& effectName();
    3737
     38        virtual bool isSourceInput() { return true; }
    3839        virtual FloatRect calculateEffectRect(Filter*);
    3940        void apply(Filter*);
  • trunk/WebCore/svg/graphics/filters/SVGFETile.cpp

    r44655 r44840  
    11/*
    22    Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.com>
     3                  2009 Dirk Schulze <krit@webkit.org>
    34
    45    This library is free software; you can redistribute it and/or
     
    2425
    2526#include "Filter.h"
     27#include "GraphicsContext.h"
     28#include "Pattern.h"
     29#include "TransformationMatrix.h"
    2630#include "SVGRenderTreeAsText.h"
    2731
     
    4549}
    4650
    47 void FETile::apply(Filter*)
     51void FETile::apply(Filter* filter)
    4852{
     53    m_in->apply(filter);
     54    if (!m_in->resultImage())
     55        return;
     56
     57    GraphicsContext* filterContext = getEffectContext();
     58    if (!filterContext)
     59        return;
     60
     61    IntRect tileRect = enclosingIntRect(m_in->subRegion());
     62
     63    // Source input needs more attention. It has the size of the filterRegion but gives the
     64    // size of the cutted sourceImage back. This is part of the specification and optimization.
     65    if (m_in->isSourceInput())
     66        tileRect = enclosingIntRect(filter->filterRegion());
     67
     68    OwnPtr<ImageBuffer> tileImage = ImageBuffer::create(tileRect.size(), false);
     69    GraphicsContext* tileImageContext = tileImage->context();
     70    tileImageContext->drawImage(m_in->resultImage()->image(), IntPoint());
     71    RefPtr<Pattern> pattern = Pattern::create(tileImage->image(), true, true);
     72
     73    TransformationMatrix matrix;
     74    matrix.translate(m_in->subRegion().x() - subRegion().x(), m_in->subRegion().y() - subRegion().y());
     75    pattern.get()->setPatternSpaceTransform(matrix);
     76
     77    filterContext->setFillPattern(pattern);
     78    filterContext->fillRect(FloatRect(FloatPoint(), subRegion().size()));
    4979}
    5080
Note: See TracChangeset for help on using the changeset viewer.