Chromium Code Reviews| Index: third_party/WebKit/Source/core/paint/PaintLayer.cpp |
| diff --git a/third_party/WebKit/Source/core/paint/PaintLayer.cpp b/third_party/WebKit/Source/core/paint/PaintLayer.cpp |
| index ded24777fc93352efa5270495cbf6fd8340df234..c800588ef9d07d2dc95d0e24a2aa304851827115 100644 |
| --- a/third_party/WebKit/Source/core/paint/PaintLayer.cpp |
| +++ b/third_party/WebKit/Source/core/paint/PaintLayer.cpp |
| @@ -1061,7 +1061,7 @@ LayoutRect PaintLayer::transparencyClipBox(const PaintLayer* layer, const PaintL |
| // paints unfragmented. |
| LayoutRect clipRect = layer->physicalBoundingBox(layer); |
| expandClipRectForDescendantsAndReflection(clipRect, layer, layer, transparencyBehavior, subPixelAccumulation, globalPaintFlags); |
| - clipRect.expand(layer->layoutObject()->style()->filterOutsets()); |
| + clipRect.expand(layer->filterOutsets()); |
| LayoutRect result = transform.mapRect(clipRect); |
| if (!paginationLayer) |
| return result; |
| @@ -1080,7 +1080,7 @@ LayoutRect PaintLayer::transparencyClipBox(const PaintLayer* layer, const PaintL |
| LayoutRect clipRect = layer->fragmentsBoundingBox(rootLayer); |
| expandClipRectForDescendantsAndReflection(clipRect, layer, rootLayer, transparencyBehavior, subPixelAccumulation, globalPaintFlags); |
| - clipRect.expand(layer->layoutObject()->style()->filterOutsets()); |
| + clipRect.expand(layer->filterOutsets()); |
| clipRect.move(subPixelAccumulation); |
| return clipRect; |
| } |
| @@ -2195,7 +2195,7 @@ LayoutRect PaintLayer::boundingBoxForCompositing(const PaintLayer* ancestorLayer |
| // FIXME: We can optimize the size of the composited layers, by not enlarging |
| // filtered areas with the outsets if we know that the filter is going to render in hardware. |
| // https://bugs.webkit.org/show_bug.cgi?id=81239 |
| - result.expand(m_layoutObject->style()->filterOutsets()); |
| + result.expand(filterOutsets()); |
| } |
| if (transform() && paintsWithTransform(GlobalPaintNormalPhase) && (this != ancestorLayer || options == MaybeIncludeTransformForAncestorLayer)) |
| @@ -2573,7 +2573,7 @@ FilterOperations computeFilterOperationsHandleReferenceFilters(const FilterOpera |
| } // unnamed namespace |
| -FilterOperations PaintLayer::computeFilterOperations(const ComputedStyle& style) |
| +FilterOperations PaintLayer::computeFilterOperations(const ComputedStyle& style) const |
| { |
| return computeFilterOperationsHandleReferenceFilters(style.filter(), style.effectiveZoom(), enclosingElement()); |
| } |
| @@ -2583,6 +2583,13 @@ FilterOperations PaintLayer::computeBackdropFilterOperations(const ComputedStyle |
| return computeFilterOperationsHandleReferenceFilters(style.backdropFilter(), style.effectiveZoom(), enclosingElement()); |
| } |
| +FilterOutsets PaintLayer::filterOutsets() const |
| +{ |
| + // Ensure the filter-chain is refreshed wrt reference filters. |
| + filterEffectBuilder(); |
| + return layoutObject()->style()->filterOutsets(); |
| +} |
| + |
| void PaintLayer::updateOrRemoveFilterClients() |
| { |
| if (!hasFilter()) { |
| @@ -2602,23 +2609,33 @@ void PaintLayer::updateOrRemoveFilterEffectBuilder() |
| // so we always need to run updateOrRemoveFilterEffectBuilder after the composited |
| // mode might have changed for this layer. |
| if (!paintsWithFilters()) { |
| - // Don't delete the whole filter info here, because we might use it |
| - // for loading CSS shader files. |
| - if (PaintLayerFilterInfo* filterInfo = this->filterInfo()) |
| - filterInfo->setBuilder(nullptr); |
| - |
| + removeFilterInfoIfNeeded(); |
|
Stephen White
2015/11/19 17:50:41
Could you explain the rationale for this change?
fs
2015/11/19 18:34:24
Just based on the comment about "CSS shader files"
|
| return; |
| } |
| PaintLayerFilterInfo* filterInfo = ensureFilterInfo(); |
| + if (filterInfo->builder()) |
| + filterInfo->builder()->reset(); |
| +} |
| + |
| +FilterEffectBuilder* PaintLayer::filterEffectBuilder() const |
| +{ |
| + PaintLayerFilterInfo* filterInfo = this->filterInfo(); |
| + if (!filterInfo) |
| + return nullptr; |
| + |
| if (!filterInfo->builder()) |
| filterInfo->setBuilder(FilterEffectBuilder::create()); |
| + // TODO(fs): Could check builder()->lastEffect() here to avoid rebuilding the filter chain. |
|
Stephen White
2015/11/19 17:50:41
It does seem to be unpleasant to be doing this on
fs
2015/11/19 18:34:24
Indeed.
|
| + const ComputedStyle& style = layoutObject()->styleRef(); |
| // If the filter fails to build, remove it from the layer. It will still attempt to |
| // go through regular processing (e.g. compositing), but never apply anything. |
| - float zoom = layoutObject()->style() ? layoutObject()->style()->effectiveZoom() : 1.0f; |
| - if (!filterInfo->builder()->build(toElement(enclosingElement()), computeFilterOperations(layoutObject()->styleRef()), zoom)) |
| + float zoom = style.effectiveZoom(); |
| + if (!filterInfo->builder()->build(toElement(enclosingElement()), computeFilterOperations(style), zoom)) |
| filterInfo->setBuilder(nullptr); |
| + |
| + return filterInfo->builder(); |
| } |
| void PaintLayer::filterNeedsPaintInvalidation() |