-
Notifications
You must be signed in to change notification settings - Fork 15k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Replace ClearFilterData with InvalidateFilterData
- Loading branch information
Showing
3 changed files
with
133 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 0 additions & 116 deletions
116
patches/chromium/fix_svg_filter_data_invalidation_for_empty_containers.patch
This file was deleted.
Oops, something went wrong.
132 changes: 132 additions & 0 deletions
132
patches/chromium/replace_clearfilterdata_with_invalidatefilterdata.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Raymond Zhao <raymondzhao@microsoft.com> | ||
Date: Wed, 10 Feb 2021 12:03:34 -0800 | ||
Subject: Replace ClearFilterData with InvalidateFilterData | ||
|
||
This is a hand-patch of https://chromium-review.googlesource.com/c/chromium/src/+/2566992. | ||
|
||
Firstly, the InvalidateFilterData function was copied over. Then, the ClearFilterData function was deleted, and any calls to it were replaced with InvalidateFilterData. Redundant calls were removed. | ||
|
||
The InvalidateFilterData function in this patch contains a fix for SVG content sometimes failing to appear after modification https://bugs.chromium.org/p/chromium/issues/detail?id=1154050. | ||
|
||
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_resource_container.cc b/third_party/blink/renderer/core/layout/svg/layout_svg_resource_container.cc | ||
index c7093ea1724dc99a26c3eef033d7ef13c2888f54..8bc6ab492bba91b5c155982e1b145aa68f43dd97 100644 | ||
--- a/third_party/blink/renderer/core/layout/svg/layout_svg_resource_container.cc | ||
+++ b/third_party/blink/renderer/core/layout/svg/layout_svg_resource_container.cc | ||
@@ -227,16 +227,12 @@ static inline void RemoveFromCacheAndInvalidateDependencies( | ||
if (resources->HasClipOrMaskOrFilter()) { | ||
InvalidationModeMask invalidation_mask = | ||
SVGResourceClient::kBoundariesInvalidation; | ||
- bool filter_data_invalidated = false; | ||
if (resources->Filter()) { | ||
- filter_data_invalidated = client->ClearFilterData(); | ||
- invalidation_mask |= | ||
- filter_data_invalidated ? SVGResourceClient::kPaintInvalidation : 0; | ||
+ client->InvalidateFilterData(); | ||
+ invalidation_mask |= SVGResourceClient::kPaintInvalidation; | ||
} | ||
LayoutSVGResourceContainer::MarkClientForInvalidation(object, | ||
invalidation_mask); | ||
- if (filter_data_invalidated) | ||
- client->MarkFilterDataDirty(); | ||
} | ||
} | ||
|
||
diff --git a/third_party/blink/renderer/core/layout/svg/svg_resources.cc b/third_party/blink/renderer/core/layout/svg/svg_resources.cc | ||
index f37cb5c3052d72ab15e769b29f8456e7ced9b5af..41ec00a53c1bb1c587b42f74867af4adab7e8641 100644 | ||
--- a/third_party/blink/renderer/core/layout/svg/svg_resources.cc | ||
+++ b/third_party/blink/renderer/core/layout/svg/svg_resources.cc | ||
@@ -604,12 +604,7 @@ void SVGResources::ClearClipPathFilterMask(SVGElement& element, | ||
old_reference_clip->RemoveClient(*client); | ||
if (style->HasFilter()) { | ||
style->Filter().RemoveClient(*client); | ||
- if (client->ClearFilterData()) { | ||
- LayoutObject* layout_object = element.GetLayoutObject(); | ||
- LayoutSVGResourceContainer::MarkClientForInvalidation( | ||
- *layout_object, SVGResourceClient::kPaintInvalidation); | ||
- client->MarkFilterDataDirty(); | ||
- } | ||
+ client->InvalidateFilterData(); | ||
} | ||
if (StyleSVGResource* masker_resource = style->SvgStyle().MaskerResource()) | ||
masker_resource->RemoveClient(*client); | ||
@@ -712,14 +707,10 @@ void SVGElementResourceClient::ResourceContentChanged( | ||
return; | ||
} | ||
|
||
- const bool filter_data_invalidated = ClearFilterData(); | ||
- if (filter_data_invalidated) | ||
- invalidation_mask |= SVGResourceClient::kPaintInvalidation; | ||
+ InvalidateFilterData(); | ||
|
||
LayoutSVGResourceContainer::MarkClientForInvalidation(*layout_object, | ||
invalidation_mask); | ||
- if (filter_data_invalidated) | ||
- MarkFilterDataDirty(); | ||
|
||
bool needs_layout = | ||
invalidation_mask & SVGResourceClient::kLayoutInvalidation; | ||
@@ -729,12 +720,8 @@ void SVGElementResourceClient::ResourceContentChanged( | ||
|
||
void SVGElementResourceClient::ResourceElementChanged() { | ||
if (LayoutObject* layout_object = element_->GetLayoutObject()) { | ||
- ClearFilterData(); | ||
+ InvalidateFilterData(); | ||
SVGResourcesCache::ResourceReferenceChanged(*layout_object); | ||
- // TODO(fs): If the resource element (for a filter) doesn't actually change | ||
- // we don't need to perform the associated invalidations. | ||
- layout_object->SetNeedsPaintPropertyUpdate(); | ||
- MarkFilterDataDirty(); | ||
} | ||
} | ||
|
||
@@ -801,11 +788,16 @@ void SVGElementResourceClient::UpdateFilterData( | ||
filter_data_dirty_ = false; | ||
} | ||
|
||
-bool SVGElementResourceClient::ClearFilterData() { | ||
- FilterData* filter_data = filter_data_.Release(); | ||
- if (filter_data) | ||
+void SVGElementResourceClient::InvalidateFilterData() { | ||
+ // If we performed an "optimized" invalidation via FilterPrimitiveChanged(), | ||
+ // we could have set |filter_data_dirty_| but not cleared |filter_data_|. | ||
+ if (filter_data_dirty_ && !filter_data_) | ||
+ return; | ||
+ if (FilterData* filter_data = filter_data_.Release()) | ||
filter_data->Dispose(); | ||
- return !!filter_data; | ||
+ LayoutObject* layout_object = element_->GetLayoutObject(); | ||
+ layout_object->SetNeedsPaintPropertyUpdate(); | ||
+ MarkFilterDataDirty(); | ||
} | ||
|
||
void SVGElementResourceClient::MarkFilterDataDirty() { | ||
diff --git a/third_party/blink/renderer/core/layout/svg/svg_resources.h b/third_party/blink/renderer/core/layout/svg/svg_resources.h | ||
index bfe056704b698d2189e5b759040f4f6cb3c54308..3416de3d5e062a31a0beb2df4d7398d2d435ec6a 100644 | ||
--- a/third_party/blink/renderer/core/layout/svg/svg_resources.h | ||
+++ b/third_party/blink/renderer/core/layout/svg/svg_resources.h | ||
@@ -228,7 +228,7 @@ class SVGElementResourceClient final | ||
const QualifiedName& attribute) override; | ||
|
||
void UpdateFilterData(CompositorFilterOperations&); | ||
- bool ClearFilterData(); | ||
+ void InvalidateFilterData(); | ||
void MarkFilterDataDirty(); | ||
|
||
void Trace(Visitor*) const override; | ||
diff --git a/third_party/blink/renderer/core/layout/svg/svg_resources_cache.cc b/third_party/blink/renderer/core/layout/svg/svg_resources_cache.cc | ||
index b9aea888de151de41591ec9fd76ef4a3c0f4b017..c94ad94190dcd280b80ed685955c94fedc5a077a 100644 | ||
--- a/third_party/blink/renderer/core/layout/svg/svg_resources_cache.cc | ||
+++ b/third_party/blink/renderer/core/layout/svg/svg_resources_cache.cc | ||
@@ -99,9 +99,8 @@ void SVGResourcesCache::ClientLayoutChanged(LayoutObject& object) { | ||
invalidation_flags = SVGResourceClient::kBoundariesInvalidation; | ||
bool filter_data_invalidated = false; | ||
if (resources->Filter()) { | ||
- filter_data_invalidated = client->ClearFilterData(); | ||
- invalidation_flags |= | ||
- filter_data_invalidated ? SVGResourceClient::kPaintInvalidation : 0; | ||
+ client->InvalidateFilterData(); | ||
+ invalidation_flags |= SVGResourceClient::kPaintInvalidation; | ||
} | ||
if (LayoutSVGResourcePaintServer* fill = resources->Fill()) { | ||
fill->RemoveClientFromCache(*client); |