⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 286546 in webkit


Ignore:
Timestamp:
Dec 6, 2021, 10:20:43 AM (5 years ago)
Author:
Said Abou-Hallawa
Message:

[GPU Process] (REGRESSION r285597): Set the filterRegion of the CSSFilter after it is created
https://bugs.webkit.org/show_bug.cgi?id=233849

Reviewed by Cameron McCormack.

Source/WebCore:

In this patch:

  1. sourceImageRect is no longer passed as an argument to SVGFilter. It should be passed only when SVGFilter::apply() is called.
  1. CSSFilter::create() will create and build the FilterFunctions from the FilterOperations. So we have to pass the targetBoundingBox since the FilterEffects will need it when calculating the outsets.
  1. The steps in RenderLayerFilters::beginFilterEffect() are: a) Recreate the CSSFilter if the targetBoundingBox changes. b) Calculate the filterRegion = targetBoundingBox + outsets c) Clamp the filterRegion if needed. This will change the filterScale. d) Set sourceImageRect = filterRegion. e) Recreate the sourceImage if needed. f) setup the context for drawing the target renderer.
  1. Managing the targetBoundingBox and the filterRegion is moved from CSSFilter to RenderLayerFilters.
  • css/CSSFilterImageValue.cpp:

(WebCore::CSSFilterImageValue::image):

  • platform/graphics/filters/Filter.cpp:

(WebCore::Filter::Filter):

  • platform/graphics/filters/Filter.h:

(WebCore::Filter::Filter):

  • rendering/CSSFilter.cpp:

(WebCore::CSSFilter::create):
(WebCore::CSSFilter::CSSFilter):
(WebCore::createSVGFilter):
(WebCore::CSSFilter::buildFilterFunctions):
(WebCore::CSSFilter::apply):
(WebCore::CSSFilter::setFilterRegion):
(WebCore::m_hasFilterThatShouldBeRestrictedBySecurityOrigin): Deleted.
(WebCore::CSSFilter::updateBackingStoreRect): Deleted.
(WebCore::CSSFilter::computeSourceImageRectForDirtyRect): Deleted.
(WebCore::CSSFilter::setSourceImageRect): Deleted.

  • rendering/CSSFilter.h:
  • rendering/RenderLayerFilters.cpp:

(WebCore::RenderLayerFilters::buildFilter):
(WebCore::RenderLayerFilters::allocateBackingStoreIfNeeded):
(WebCore::RenderLayerFilters::beginFilterEffect):
(WebCore::RenderLayerFilters::applyFilterEffect):
(WebCore::RenderLayerFilters::allocateBackingStore): Deleted.

  • rendering/RenderLayerFilters.h:
  • rendering/svg/RenderSVGResourceFilter.cpp:

(WebCore::RenderSVGResourceFilter::applyResource):

  • rendering/svg/SVGRenderTreeAsText.cpp:

(WebCore::writeSVGResourceContainer):

  • svg/graphics/filters/SVGFilter.cpp:

(WebCore::SVGFilter::create):
(WebCore::SVGFilter::SVGFilter):

  • svg/graphics/filters/SVGFilter.h:

LayoutTests:

Unskip layout tests which were skipped in r285597.

Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r286532 r286546  
     12021-12-06  Said Abou-Hallawa  <said@apple.com>
     2
     3        [GPU Process] (REGRESSION r285597): Set the filterRegion of the CSSFilter after it is created
     4        https://bugs.webkit.org/show_bug.cgi?id=233849
     5
     6        Reviewed by Cameron McCormack.
     7
     8        Unskip layout tests which were skipped in r285597.
     9
     10        * TestExpectations:
     11
    1122021-12-04  Antoine Quint  <graouts@webkit.org>
    213
  • trunk/LayoutTests/TestExpectations

    r286526 r286546  
    51645164js/dom/reflect-set-onto-dom.html [ Skip ]
    51655165userscripts/user-script-plugin-document.html [ Skip ]
    5166 
    5167 # These filter related failures should be fixed once webkit.org/b/232705 is resolved
    5168 webkit.org/b/232705 compositing/filters/sw-nested-shadow-overlaps-hw-nested-shadow.html [ Skip ]
    5169 webkit.org/b/232705 compositing/filters/sw-shadow-overlaps-hw-layer.html [ Skip ]
    5170 webkit.org/b/232705 compositing/filters/sw-shadow-overlaps-hw-shadow.html [ Skip ]
    5171 webkit.org/b/232705 css3/filters/effect-reference-delete.html [ Skip ]
    5172 webkit.org/b/232705 css3/filters/svg-blur-filter-clipped.html [ Skip ]
    5173 webkit.org/b/232705 fast/filter-image/background-filter-image.html [ Skip ]
    5174 webkit.org/b/232705 fast/filter-image/filter-image-blur.html [ Skip ]
    5175 webkit.org/b/232705 fast/filter-image/filter-image-svg.html [ Skip ]
    5176 webkit.org/b/232705 fast/filter-image/filter-image.html [ Skip ]
    5177 webkit.org/b/232705 imported/mozilla/svg/dynamic-filter-contents-01a.svg [ Skip ]
    5178 webkit.org/b/232705 imported/mozilla/svg/filters/feComposite-2.svg [ Skip ]
    5179 webkit.org/b/232705 imported/mozilla/svg/filters/feSpecularLighting-1.svg [ Skip ]
    5180 webkit.org/b/232705 svg/custom/resources-css-scaled.html [ Skip ]
    5181 webkit.org/b/232705 svg/filters/feLighting-clipped.svg [ Skip ]
  • trunk/Source/WebCore/ChangeLog

    r286545 r286546  
     12021-12-06  Said Abou-Hallawa  <said@apple.com>
     2        [GPU Process] (REGRESSION r285597): Set the filterRegion of the CSSFilter after it is created
     3        https://bugs.webkit.org/show_bug.cgi?id=233849
     4
     5        Reviewed by Cameron McCormack.
     6
     7        In this patch:
     8
     9        1. sourceImageRect is no longer passed as an argument to SVGFilter. It
     10           should be passed only when SVGFilter::apply() is called.
     11
     12        2. CSSFilter::create() will create and build the FilterFunctions from the
     13           FilterOperations. So we have to pass the targetBoundingBox since the
     14           FilterEffects will need it when calculating the outsets.
     15
     16        3. The steps in RenderLayerFilters::beginFilterEffect() are:
     17           a) Recreate the CSSFilter if the targetBoundingBox changes.
     18           b) Calculate the filterRegion = targetBoundingBox + outsets
     19           c) Clamp the filterRegion if needed. This will change the filterScale.
     20           d) Set sourceImageRect = filterRegion.
     21           e) Recreate the sourceImage if needed.
     22           f) setup the context for drawing the target renderer.
     23
     24        4. Managing the targetBoundingBox and the filterRegion is moved from
     25           CSSFilter to RenderLayerFilters.
     26
     27        * css/CSSFilterImageValue.cpp:
     28        (WebCore::CSSFilterImageValue::image):
     29        * platform/graphics/filters/Filter.cpp:
     30        (WebCore::Filter::Filter):
     31        * platform/graphics/filters/Filter.h:
     32        (WebCore::Filter::Filter):
     33        * rendering/CSSFilter.cpp:
     34        (WebCore::CSSFilter::create):
     35        (WebCore::CSSFilter::CSSFilter):
     36        (WebCore::createSVGFilter):
     37        (WebCore::CSSFilter::buildFilterFunctions):
     38        (WebCore::CSSFilter::apply):
     39        (WebCore::CSSFilter::setFilterRegion):
     40        (WebCore::m_hasFilterThatShouldBeRestrictedBySecurityOrigin): Deleted.
     41        (WebCore::CSSFilter::updateBackingStoreRect): Deleted.
     42        (WebCore::CSSFilter::computeSourceImageRectForDirtyRect): Deleted.
     43        (WebCore::CSSFilter::setSourceImageRect): Deleted.
     44        * rendering/CSSFilter.h:
     45        * rendering/RenderLayerFilters.cpp:
     46        (WebCore::RenderLayerFilters::buildFilter):
     47        (WebCore::RenderLayerFilters::allocateBackingStoreIfNeeded):
     48        (WebCore::RenderLayerFilters::beginFilterEffect):
     49        (WebCore::RenderLayerFilters::applyFilterEffect):
     50        (WebCore::RenderLayerFilters::allocateBackingStore): Deleted.
     51        * rendering/RenderLayerFilters.h:
     52        * rendering/svg/RenderSVGResourceFilter.cpp:
     53        (WebCore::RenderSVGResourceFilter::applyResource):
     54        * rendering/svg/SVGRenderTreeAsText.cpp:
     55        (WebCore::writeSVGResourceContainer):
     56        * svg/graphics/filters/SVGFilter.cpp:
     57        (WebCore::SVGFilter::create):
     58        (WebCore::SVGFilter::SVGFilter):
     59        * svg/graphics/filters/SVGFilter.h:
     60
    1612021-12-06  Alex Christensen  <achristensen@webkit.org>
    262
  • trunk/Source/WebCore/css/CSSFilterImageValue.cpp

    r286287 r286546  
    125125    sourceImage->context().drawImage(*image, sourceImageRect);
    126126
    127     auto cssFilter = CSSFilter::create(m_filterOperations, renderingMode);
     127    auto cssFilter = CSSFilter::create(renderer, m_filterOperations, renderingMode, FloatSize { 1, 1 }, Filter::ClipOperation::Intersect, sourceImageRect);
     128    if (!cssFilter)
     129        return &Image::nullImage();
    128130
    129     cssFilter->setSourceImageRect(sourceImageRect);
    130     if (!cssFilter->buildFilterFunctions(renderer, m_filterOperations))
    131         return &Image::nullImage();
     131    cssFilter->setFilterRegion(sourceImageRect);
    132132
    133133    if (auto image = sourceImage->filteredImage(*cssFilter))
  • trunk/Source/WebCore/platform/graphics/filters/Filter.cpp

    r286538 r286546  
    3333namespace WebCore {
    3434
    35 Filter::Filter(Filter::Type filterType, RenderingMode renderingMode, const FloatSize& filterScale, ClipOperation clipOperation)
     35Filter::Filter(Filter::Type filterType, RenderingMode renderingMode, const FloatSize& filterScale, ClipOperation clipOperation, const FloatRect& filterRegion)
    3636    : FilterFunction(filterType)
    3737    , m_renderingMode(renderingMode)
    3838    , m_filterScale(filterScale)
    3939    , m_clipOperation(clipOperation)
    40 {
    41 }
    42 
    43 Filter::Filter(Filter::Type filterType, RenderingMode renderingMode, const FloatSize& filterScale, const FloatRect& sourceImageRect, const FloatRect& filterRegion, ClipOperation clipOperation)
    44     : FilterFunction(filterType)
    45     , m_renderingMode(renderingMode)
    46     , m_filterScale(filterScale)
    47     , m_sourceImageRect(sourceImageRect)
    4840    , m_filterRegion(filterRegion)
    49     , m_clipOperation(clipOperation)
    5041{
    5142}
  • trunk/Source/WebCore/platform/graphics/filters/Filter.h

    r286538 r286546  
    7878protected:
    7979    using FilterFunction::FilterFunction;
    80     Filter(Filter::Type, RenderingMode, const FloatSize& filterScale, ClipOperation = ClipOperation::Intersect);
    81     Filter(Filter::Type, RenderingMode, const FloatSize& filterScale, const FloatRect& sourceImageRect, const FloatRect& filterRegion, ClipOperation = ClipOperation::Intersect);
     80    Filter(Filter::Type, RenderingMode, const FloatSize& filterScale, ClipOperation, const FloatRect& filterRegion = { });
    8281
    8382private:
    8483    RenderingMode m_renderingMode;
    85 
    8684    FloatSize m_filterScale;
    87     FloatRect m_sourceImageRect;
     85    ClipOperation m_clipOperation;
    8886    FloatRect m_filterRegion;
    8987
     88    // FIXME: these should not be members of Filter. They should be passed to Filter::apply().
     89    FloatRect m_sourceImageRect;
    9090    RefPtr<ImageBuffer> m_sourceImage;
    91 
    92     ClipOperation m_clipOperation;
    9391};
    9492
  • trunk/Source/WebCore/rendering/CSSFilter.cpp

    r286538 r286546  
    4545namespace WebCore {
    4646
    47 RefPtr<CSSFilter> CSSFilter::create(const FilterOperations& operations, RenderingMode renderingMode, float scaleFactor, ClipOperation clipOperation)
     47RefPtr<CSSFilter> CSSFilter::create(RenderElement& renderer, const FilterOperations& operations, RenderingMode renderingMode, const FloatSize& filterScale, ClipOperation clipOperation, const FloatRect& targetBoundingBox)
    4848{
    4949    bool hasFilterThatMovesPixels = operations.hasFilterThatMovesPixels();
    5050    bool hasFilterThatShouldBeRestrictedBySecurityOrigin = operations.hasFilterThatShouldBeRestrictedBySecurityOrigin();
    5151
    52     return adoptRef(*new CSSFilter(renderingMode, scaleFactor, clipOperation, hasFilterThatMovesPixels, hasFilterThatShouldBeRestrictedBySecurityOrigin));
     52    auto filter = adoptRef(*new CSSFilter(renderingMode, filterScale, clipOperation, hasFilterThatMovesPixels, hasFilterThatShouldBeRestrictedBySecurityOrigin));
     53
     54    if (!filter->buildFilterFunctions(renderer, operations, targetBoundingBox))
     55        return nullptr;
     56
     57    return filter;
    5358}
    5459
     
    5863}
    5964
    60 CSSFilter::CSSFilter(RenderingMode renderingMode, float scaleFactor, ClipOperation clipOperation, bool hasFilterThatMovesPixels, bool hasFilterThatShouldBeRestrictedBySecurityOrigin)
    61     : Filter(Filter::Type::CSSFilter, renderingMode, FloatSize { scaleFactor, scaleFactor }, clipOperation)
     65CSSFilter::CSSFilter(RenderingMode renderingMode, const FloatSize& filterScale, ClipOperation clipOperation, bool hasFilterThatMovesPixels, bool hasFilterThatShouldBeRestrictedBySecurityOrigin)
     66    : Filter(Filter::Type::CSSFilter, renderingMode, filterScale, clipOperation)
    6267    , m_hasFilterThatMovesPixels(hasFilterThatMovesPixels)
    6368    , m_hasFilterThatShouldBeRestrictedBySecurityOrigin(hasFilterThatShouldBeRestrictedBySecurityOrigin)
     
    214219}
    215220
    216 static RefPtr<SVGFilter> createSVGFilter(CSSFilter& filter, const ReferenceFilterOperation& filterOperation, RenderElement& renderer, FilterEffect& previousEffect)
     221static RefPtr<SVGFilter> createSVGFilter(CSSFilter& filter, const ReferenceFilterOperation& filterOperation, RenderElement& renderer, const FloatRect& targetBoundingBox, FilterEffect& previousEffect)
    217222{
    218223    auto& referencedSVGResources = renderer.ensureReferencedSVGResources();
     
    228233
    229234    SVGFilterBuilder builder;
    230     return SVGFilter::create(*filterElement, builder, filter.renderingMode(), filter.filterScale(), filter.sourceImageRect(), filter.filterRegion(), filter.clipOperation(), previousEffect);
    231 }
    232 
    233 bool CSSFilter::buildFilterFunctions(RenderElement& renderer, const FilterOperations& operations)
     235    return SVGFilter::create(*filterElement, builder, filter.renderingMode(), filter.filterScale(), filter.clipOperation(), targetBoundingBox, previousEffect);
     236}
     237
     238bool CSSFilter::buildFilterFunctions(RenderElement& renderer, const FilterOperations& operations, const FloatRect& targetBoundingBox)
    234239{
    235240    m_functions.clear();
     
    288293
    289294        case FilterOperation::REFERENCE:
    290             filter = createSVGFilter(*this, downcast<ReferenceFilterOperation>(*operation), renderer, *previousEffect);
     295            filter = createSVGFilter(*this, downcast<ReferenceFilterOperation>(*operation), renderer, targetBoundingBox, *previousEffect);
    291296            effect = nullptr;
    292297            break;
     
    331336}
    332337
    333 bool CSSFilter::updateBackingStoreRect(const FloatRect& filterRect)
    334 {
    335     if (filterRect.isEmpty() || ImageBuffer::sizeNeedsClamping(filterRect.size()))
    336         return false;
    337 
    338     if (filterRect == sourceImageRect())
    339         return false;
    340 
    341     setSourceImageRect(filterRect);
    342     return true;
    343 }
    344 
    345338RefPtr<FilterEffect> CSSFilter::lastEffect() const
    346339{
     
    379372{
    380373    for (auto& function : m_functions) {
     374        if (function->isSVGFilter())
     375            downcast<SVGFilter>(function.ptr())->setSourceImageRect(sourceImageRect());
    381376        if (!function->apply(*this))
    382377            return nullptr;
     
    385380}
    386381
    387 LayoutRect CSSFilter::computeSourceImageRectForDirtyRect(const LayoutRect& filterBoxRect, const LayoutRect& dirtyRect)
    388 {
    389     // The result of this function is the area in the "filterBoxRect" that needs to be repainted, so that we fully cover the "dirtyRect".
    390     auto rectForRepaint = dirtyRect;
    391     if (hasFilterThatMovesPixels())
    392         rectForRepaint += outsets();
    393     rectForRepaint.intersect(filterBoxRect);
    394     return rectForRepaint;
    395 }
    396 
    397 void CSSFilter::setSourceImageRect(const FloatRect& sourceImageRect)
    398 {
    399     Filter::setFilterRegion(sourceImageRect);
    400     Filter::setSourceImageRect(sourceImageRect);
     382void CSSFilter::setFilterRegion(const FloatRect& filterRegion)
     383{
     384    Filter::setFilterRegion(filterRegion);
    401385
    402386    for (auto& function : m_functions) {
    403         if (function->isSVGFilter()) {
    404             downcast<SVGFilter>(function.ptr())->setFilterRegion(sourceImageRect);
    405             downcast<SVGFilter>(function.ptr())->setSourceImageRect(sourceImageRect);
    406         }
     387        if (function->isSVGFilter())
     388            downcast<SVGFilter>(function.ptr())->setFilterRegion(filterRegion);
    407389    }
     390
     391    clampFilterRegionIfNeeded();
    408392}
    409393
  • trunk/Source/WebCore/rendering/CSSFilter.h

    r286538 r286546  
    4343    WTF_MAKE_FAST_ALLOCATED;
    4444public:
    45     static RefPtr<CSSFilter> create(const FilterOperations&, RenderingMode, float scaleFactor = 1, ClipOperation = ClipOperation::Intersect);
     45    static RefPtr<CSSFilter> create(RenderElement&, const FilterOperations&, RenderingMode, const FloatSize& filterScale, ClipOperation, const FloatRect& targetBoundingBox);
    4646    WEBCORE_EXPORT static RefPtr<CSSFilter> create(Vector<Ref<FilterFunction>>&&);
    4747
    4848    const Vector<Ref<FilterFunction>>& functions() const { return m_functions; }
    4949
    50     void setSourceImageRect(const FloatRect&);
    51     bool buildFilterFunctions(RenderElement&, const FilterOperations&);
     50    void setFilterRegion(const FloatRect&);
    5251
    5352    bool hasFilterThatMovesPixels() const { return m_hasFilterThatMovesPixels; }
     
    6059    RefPtr<FilterImage> apply() final;
    6160
    62     bool updateBackingStoreRect(const FloatRect& filterRect);
    63 
    64     LayoutRect computeSourceImageRectForDirtyRect(const LayoutRect& filterBoxRect, const LayoutRect& dirtyRect);
    65 
    6661private:
    67     CSSFilter(RenderingMode, float scaleFactor, ClipOperation, bool hasFilterThatMovesPixels, bool hasFilterThatShouldBeRestrictedBySecurityOrigin);
     62    CSSFilter(RenderingMode, const FloatSize& filterScale, ClipOperation, bool hasFilterThatMovesPixels, bool hasFilterThatShouldBeRestrictedBySecurityOrigin);
    6863    CSSFilter(Vector<Ref<FilterFunction>>&&);
     64   
     65    bool buildFilterFunctions(RenderElement&, const FilterOperations&, const FloatRect& targetBoundingBox);
    6966
    7067#if USE(CORE_IMAGE)
  • trunk/Source/WebCore/rendering/RenderLayerFilters.cpp

    r286538 r286546  
    122122    // go through regular processing (e.g. compositing), but never apply anything.
    123123    // FIXME: this rebuilds the entire effects chain even if the filter style didn't change.
    124     m_filter = CSSFilter::create(renderer.style().filter(), renderingMode, scaleFactor, Filter::ClipOperation::Unite);
     124    m_filter = CSSFilter::create(renderer, renderer.style().filter(), renderingMode, FloatSize { scaleFactor, scaleFactor }, Filter::ClipOperation::Unite, m_targetBoundingBox);
    125125}
    126126
     
    130130}
    131131
    132 void RenderLayerFilters::allocateBackingStore(const GraphicsContext& targetContext)
     132void RenderLayerFilters::allocateBackingStoreIfNeeded(const GraphicsContext& targetContext)
    133133{
    134134    auto& filter = *m_filter;
    135     auto logicalSize = filter.scaledByFilterScale(filter.sourceImageRect().size());
     135    auto logicalSize = filter.scaledByFilterScale(m_filterRegion.size());
    136136
    137137    if (!m_sourceImage || m_sourceImage->logicalSize() != logicalSize) {
     
    152152        return nullptr;
    153153
     154    // Calculate targetBoundingBox since it will be used if the filter is created.
     155    auto targetBoundingBox = intersection(filterBoxRect, dirtyRect);
     156    if (targetBoundingBox.isEmpty())
     157        return nullptr;
     158
     159    if (m_targetBoundingBox != targetBoundingBox) {
     160        m_targetBoundingBox = targetBoundingBox;
     161        // FIXME: this rebuilds the entire effects chain even if the filter style didn't change.
     162        m_filter = CSSFilter::create(renderer, renderer.style().filter(), m_filter->renderingMode(), m_filter->filterScale(), Filter::ClipOperation::Unite, m_targetBoundingBox);
     163    }
     164
     165    if (!m_filter)
     166        return nullptr;
     167
    154168    auto& filter = *m_filter;
    155     auto filterSourceRect = filter.computeSourceImageRectForDirtyRect(filterBoxRect, dirtyRect);
    156     if (filterSourceRect.isEmpty())
    157         return nullptr;
    158 
    159     bool hasUpdatedBackingStore = filter.updateBackingStoreRect(filterSourceRect);
    160 
    161     // FIXME: this call should be moved to CSSFilter::create() when FilterEffect does not store its geometry.
    162     if (hasUpdatedBackingStore || !m_filter->lastEffect()) {
    163         // If the filter fails to build, remove it from the layer. It will still attempt to
    164         // go through regular processing (e.g. compositing), but never apply anything.
    165         if (!m_filter->buildFilterFunctions(renderer, renderer.style().filter()))
    166             return nullptr;
     169   
     170    // For CSSFilter, filterRegion = targetBoundingBox + filter->outsets()
     171    auto filterRegion = targetBoundingBox;
     172    if (filter.hasFilterThatMovesPixels()) {
     173        filterRegion += filter.outsets();
     174        filterRegion.intersect(filterBoxRect);
     175    }
     176
     177    if (filterRegion.isEmpty())
     178        return nullptr;
     179
     180    // For CSSFilter, sourceImageRect = filterRegion.
     181    bool hasUpdatedBackingStore = false;
     182    if (m_filterRegion != filterRegion) {
     183        m_filterRegion = filterRegion;
     184        hasUpdatedBackingStore = true;
    167185    }
    168186
     
    171189    else {
    172190        if (hasUpdatedBackingStore)
    173             m_repaintRect = filterSourceRect;
     191            m_repaintRect = filterRegion;
    174192        else {
    175193            m_repaintRect = dirtyRect;
    176194            m_repaintRect.unite(layerRepaintRect);
    177             m_repaintRect.intersect(filterSourceRect);
     195            m_repaintRect.intersect(filterRegion);
    178196        }
    179197    }
    180     m_paintOffset = filterSourceRect.location();
     198
     199    m_paintOffset = filterRegion.location();
    181200    resetDirtySourceRect();
    182201
    183     filter.clampFilterRegionIfNeeded();
    184 
    185     if (hasUpdatedBackingStore)
    186         allocateBackingStore(destinationContext);
     202    filter.setFilterRegion(m_filterRegion);
     203    allocateBackingStoreIfNeeded(destinationContext);
    187204
    188205    auto* sourceGraphicsContext = inputContext();
    189     if (!sourceGraphicsContext || filter.filterRegion().isEmpty() || ImageBuffer::sizeNeedsClamping(filter.filterRegion().size()))
     206    if (!sourceGraphicsContext)
    190207        return nullptr;
    191208
     
    208225    auto& filter = *m_filter;
    209226
    210     destinationContext.drawFilteredImageBuffer(m_sourceImage.get(), filter.sourceImageRect(), filter);
     227    destinationContext.drawFilteredImageBuffer(m_sourceImage.get(), m_filterRegion, filter);
    211228    filter.clearIntermediateResults();
    212229
  • trunk/Source/WebCore/rendering/RenderLayerFilters.h

    r286203 r286546  
    7171    void resetDirtySourceRect() { m_dirtySourceRect = LayoutRect(); }
    7272    GraphicsContext* inputContext();
    73     void allocateBackingStore(const GraphicsContext& targetContext);
     73    void allocateBackingStoreIfNeeded(const GraphicsContext& targetContext);
    7474
    7575    RenderLayer& m_layer;
     
    7878    Vector<CachedResourceHandle<CachedSVGDocument>> m_externalSVGReferences;
    7979
     80    LayoutRect m_targetBoundingBox;
     81    FloatRect m_filterRegion;
    8082    RefPtr<ImageBuffer> m_sourceImage;
    8183    RefPtr<CSSFilter> m_filter;
  • trunk/Source/WebCore/rendering/svg/RenderSVGResourceFilter.cpp

    r286538 r286546  
    130130    // Create the SVGFilter object.
    131131    filterData->builder = makeUnique<SVGFilterBuilder>();
    132     filterData->filter = SVGFilter::create(filterElement(), *filterData->builder, renderingMode, filterScale, filterData->drawingRegion, filterData->boundaries, targetBoundingBox);
     132    filterData->filter = SVGFilter::create(filterElement(), *filterData->builder, renderingMode, filterScale, filterData->boundaries, targetBoundingBox);
    133133    if (!filterData->filter) {
    134134        m_rendererFilterDataMap.remove(&renderer);
  • trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp

    r286392 r286546  
    432432        FloatSize dummyScale(1, 1);
    433433        SVGFilterBuilder builder;
    434         auto dummyFilter = SVGFilter::create(filter.filterElement(), builder, RenderingMode::Unaccelerated, dummyScale, dummyRect, dummyRect, dummyRect);
     434        auto dummyFilter = SVGFilter::create(filter.filterElement(), builder, RenderingMode::Unaccelerated, dummyScale, dummyRect, dummyRect);
    435435        if (dummyFilter) {
    436436            TextStream::IndentScope indentScope(ts);
  • trunk/Source/WebCore/svg/graphics/filters/SVGFilter.cpp

    r286466 r286546  
    3030namespace WebCore {
    3131
    32 RefPtr<SVGFilter> SVGFilter::create(SVGFilterElement& filterElement, SVGFilterBuilder& builder, RenderingMode renderingMode, const FloatSize& filterScale, const FloatRect& sourceImageRect, const FloatRect& filterRegion, ClipOperation clipOperation, FilterEffect& previousEffect)
     32RefPtr<SVGFilter> SVGFilter::create(SVGFilterElement& filterElement, SVGFilterBuilder& builder, RenderingMode renderingMode, const FloatSize& filterScale, ClipOperation clipOperation, const FloatRect& targetBoundingBox, FilterEffect& previousEffect)
    3333{
    34     return create(filterElement, builder, renderingMode, filterScale, sourceImageRect, filterRegion, clipOperation, filterRegion, &previousEffect);
     34    return create(filterElement, builder, renderingMode, filterScale, clipOperation, targetBoundingBox, targetBoundingBox, &previousEffect);
    3535}
    3636
    37 RefPtr<SVGFilter> SVGFilter::create(SVGFilterElement& filterElement, SVGFilterBuilder& builder, RenderingMode renderingMode, const FloatSize& filterScale, const FloatRect& sourceImageRect, const FloatRect& filterRegion, const FloatRect& targetBoundingBox)
     37RefPtr<SVGFilter> SVGFilter::create(SVGFilterElement& filterElement, SVGFilterBuilder& builder, RenderingMode renderingMode, const FloatSize& filterScale, const FloatRect& filterRegion, const FloatRect& targetBoundingBox)
    3838{
    39     return create(filterElement, builder, renderingMode, filterScale, sourceImageRect, filterRegion, ClipOperation::Intersect, targetBoundingBox, nullptr);
     39    return create(filterElement, builder, renderingMode, filterScale, ClipOperation::Intersect, filterRegion, targetBoundingBox, nullptr);
    4040}
    4141
    42 RefPtr<SVGFilter> SVGFilter::create(SVGFilterElement& filterElement, SVGFilterBuilder& builder, RenderingMode renderingMode, const FloatSize& filterScale, const FloatRect& sourceImageRect, const FloatRect& filterRegion, ClipOperation clipOperation, const FloatRect& targetBoundingBox, FilterEffect* previousEffect)
     42RefPtr<SVGFilter> SVGFilter::create(SVGFilterElement& filterElement, SVGFilterBuilder& builder, RenderingMode renderingMode, const FloatSize& filterScale, ClipOperation clipOperation, const FloatRect& filterRegion, const FloatRect& targetBoundingBox, FilterEffect* previousEffect)
    4343{
    44     auto filter = adoptRef(*new SVGFilter(renderingMode, filterScale, sourceImageRect, filterRegion, clipOperation, targetBoundingBox, filterElement.primitiveUnits()));
     44    auto filter = adoptRef(*new SVGFilter(renderingMode, filterScale, clipOperation, filterRegion, targetBoundingBox, filterElement.primitiveUnits()));
    4545
    4646    if (!previousEffect)
     
    7272}
    7373
    74 SVGFilter::SVGFilter(RenderingMode renderingMode, const FloatSize& filterScale, const FloatRect& sourceImageRect, const FloatRect& filterRegion, ClipOperation clipOperation, const FloatRect& targetBoundingBox, SVGUnitTypes::SVGUnitType primitiveUnits)
    75     : Filter(Filter::Type::SVGFilter, renderingMode, filterScale, sourceImageRect, filterRegion, clipOperation)
     74SVGFilter::SVGFilter(RenderingMode renderingMode, const FloatSize& filterScale, ClipOperation clipOperation, const FloatRect& filterRegion, const FloatRect& targetBoundingBox, SVGUnitTypes::SVGUnitType primitiveUnits)
     75    : Filter(Filter::Type::SVGFilter, renderingMode, filterScale, clipOperation, filterRegion)
    7676    , m_targetBoundingBox(targetBoundingBox)
    7777    , m_primitiveUnits(primitiveUnits)
  • trunk/Source/WebCore/svg/graphics/filters/SVGFilter.h

    r286526 r286546  
    3737class SVGFilter final : public Filter {
    3838public:
    39     static RefPtr<SVGFilter> create(SVGFilterElement&, SVGFilterBuilder&, RenderingMode, const FloatSize& filterScale, const FloatRect& sourceImageRect, const FloatRect& filterRegion, ClipOperation, FilterEffect& previousEffect);
    40     static RefPtr<SVGFilter> create(SVGFilterElement&, SVGFilterBuilder&, RenderingMode, const FloatSize& filterScale, const FloatRect& sourceImageRect, const FloatRect& filterRegion, const FloatRect& targetBoundingBox);
    41     static RefPtr<SVGFilter> create(SVGFilterElement&, SVGFilterBuilder&, RenderingMode, const FloatSize& filterScale, const FloatRect& sourceImageRect, const FloatRect& filterRegion, ClipOperation, const FloatRect& targetBoundingBox, FilterEffect* previousEffect);
     39    static RefPtr<SVGFilter> create(SVGFilterElement&, SVGFilterBuilder&, RenderingMode, const FloatSize& filterScale, ClipOperation, const FloatRect& targetBoundingBox, FilterEffect& previousEffect);
     40    static RefPtr<SVGFilter> create(SVGFilterElement&, SVGFilterBuilder&, RenderingMode, const FloatSize& filterScale, const FloatRect& filterRegion, const FloatRect& targetBoundingBox);
     41    static RefPtr<SVGFilter> create(SVGFilterElement&, SVGFilterBuilder&, RenderingMode, const FloatSize& filterScale, ClipOperation, const FloatRect& filterRegion, const FloatRect& targetBoundingBox, FilterEffect* previousEffect);
    4242
    4343    FloatRect targetBoundingBox() const { return m_targetBoundingBox; }
     
    4848
    4949private:
    50     SVGFilter(RenderingMode, const FloatSize& filterScale, const FloatRect& sourceImageRect, const FloatRect& filterRegion, ClipOperation, const FloatRect& targetBoundingBox, SVGUnitTypes::SVGUnitType primitiveUnits);
     50    SVGFilter(RenderingMode, const FloatSize& filterScale, ClipOperation, const FloatRect& filterRegion, const FloatRect& targetBoundingBox, SVGUnitTypes::SVGUnitType primitiveUnits);
    5151
    5252    // FIXME: Merge the effectBoundaries in the expression node.
Note: See TracChangeset for help on using the changeset viewer.