Commit 92b0a60d authored by Fredrik Söderqvist's avatar Fredrik Söderqvist Committed by Commit Bot

Make SVG resources invalidation flags more granular

The kPaintInvalidation flag performs both paint invalidation paint
property invalidation and clip-path cache invalidation. Split out the
two latter so that they can be used in a more targeted way and avoid
unnecessarily "wide" invalidations. For example we don't need to
invalidate neither the paint properties nor the clip-path cache when a
paint server changes.

Take this opportunity to change the invalidation flags for masks, clips
and filters to not invalidate bounds and trigger layout since they
should no longer have any effect on a clients bounds (and thus also
don't need to trigger a layout).

Add an additional kFilterCacheInvalidation flag for the invalidation of
a filter, and make that invalidation conditional.

Bug: 1028061, 1028063
Change-Id: If96237ec2b5f7a08fd41fb51e1eb3f245b809b63
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2467997Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#817120}
parent 8d7c45ba
......@@ -116,8 +116,8 @@ void LayoutSVGResourceClipper::RemoveAllClientsFromCache() {
clip_content_path_.Clear();
cached_paint_record_.reset();
local_clip_bounds_ = FloatRect();
MarkAllClientsForInvalidation(SVGResourceClient::kLayoutInvalidation |
SVGResourceClient::kBoundariesInvalidation);
MarkAllClientsForInvalidation(SVGResourceClient::kClipCacheInvalidation |
SVGResourceClient::kPaintInvalidation);
}
base::Optional<Path> LayoutSVGResourceClipper::AsPath() {
......@@ -283,14 +283,14 @@ void LayoutSVGResourceClipper::StyleDidChange(StyleDifference diff,
NOT_DESTROYED();
LayoutSVGResourceContainer::StyleDidChange(diff, old_style);
if (diff.TransformChanged()) {
MarkAllClientsForInvalidation(SVGResourceClient::kBoundariesInvalidation |
MarkAllClientsForInvalidation(SVGResourceClient::kClipCacheInvalidation |
SVGResourceClient::kPaintInvalidation);
}
}
void LayoutSVGResourceClipper::WillBeDestroyed() {
NOT_DESTROYED();
MarkAllClientsForInvalidation(SVGResourceClient::kBoundariesInvalidation |
MarkAllClientsForInvalidation(SVGResourceClient::kClipCacheInvalidation |
SVGResourceClient::kPaintInvalidation);
LayoutSVGResourceContainer::WillBeDestroyed();
}
......
......@@ -44,8 +44,8 @@ bool LayoutSVGResourceFilter::IsChildAllowed(LayoutObject* child,
void LayoutSVGResourceFilter::RemoveAllClientsFromCache() {
NOT_DESTROYED();
MarkAllClientsForInvalidation(SVGResourceClient::kLayoutInvalidation |
SVGResourceClient::kBoundariesInvalidation);
MarkAllClientsForInvalidation(SVGResourceClient::kPaintInvalidation |
SVGResourceClient::kFilterCacheInvalidation);
}
FloatRect LayoutSVGResourceFilter::ResourceBoundingBox(
......
......@@ -42,8 +42,9 @@ void LayoutSVGResourceMasker::RemoveAllClientsFromCache() {
NOT_DESTROYED();
cached_paint_record_.reset();
mask_content_boundaries_ = FloatRect();
MarkAllClientsForInvalidation(SVGResourceClient::kLayoutInvalidation |
SVGResourceClient::kBoundariesInvalidation);
MarkAllClientsForInvalidation(
SVGResourceClient::kPaintPropertiesInvalidation |
SVGResourceClient::kPaintInvalidation);
}
sk_sp<const PaintRecord> LayoutSVGResourceMasker::CreatePaintRecord(
......
......@@ -695,7 +695,8 @@ void SVGElementResourceClient::ResourceContentChanged(
return;
}
InvalidateFilterData();
if (invalidation_mask & SVGResourceClient::kFilterCacheInvalidation)
InvalidateFilterData();
if (invalidation_mask & SVGResourceClient::kPaintInvalidation) {
// Since LayoutSVGInlineTexts don't have SVGResources (they use their
......@@ -705,10 +706,14 @@ void SVGElementResourceClient::ResourceContentChanged(
// entire <text>/<tspan>/... subtree.
layout_object->SetSubtreeShouldDoFullPaintInvalidation(
PaintInvalidationReason::kSVGResource);
}
if (invalidation_mask & SVGResourceClient::kClipCacheInvalidation)
layout_object->InvalidateClipPathCache();
// Invalidate paint properties to update effects if any.
// Invalidate paint properties to update effects if any.
if (invalidation_mask & SVGResourceClient::kPaintPropertiesInvalidation)
layout_object->SetNeedsPaintPropertyUpdate();
}
if (invalidation_mask & SVGResourceClient::kBoundariesInvalidation)
layout_object->SetNeedsBoundariesUpdate();
......
......@@ -843,14 +843,15 @@ TEST_P(PaintAndRasterInvalidationTest, SVGHiddenContainer) {
UpdateAllLifecyclePhasesForTest();
// Should invalidate raster for real_rect only.
EXPECT_THAT(GetRasterInvalidationTracking()->Invalidations(),
UnorderedElementsAre(
RasterInvalidationInfo{real_rect, real_rect->DebugName(),
IntRect(155, 166, 7, 8),
PaintInvalidationReason::kFull},
RasterInvalidationInfo{real_rect, real_rect->DebugName(),
IntRect(155, 166, 7, 8),
PaintInvalidationReason::kFull}));
EXPECT_THAT(
GetRasterInvalidationTracking()->Invalidations(),
UnorderedElementsAre(
RasterInvalidationInfo{real_rect, real_rect->DebugName(),
IntRect(155, 166, 7, 8),
PaintInvalidationReason::kSVGResource},
RasterInvalidationInfo{real_rect, real_rect->DebugName(),
IntRect(155, 166, 7, 8),
PaintInvalidationReason::kSVGResource}));
GetDocument().View()->SetTracksRasterInvalidations(false);
}
......
......@@ -120,8 +120,8 @@ void SVGFilterElement::PrimitiveAttributeChanged(
void SVGFilterElement::InvalidateFilterChain() {
if (LocalSVGResource* resource = AssociatedResource()) {
resource->NotifyContentChanged(SVGResourceClient::kLayoutInvalidation |
SVGResourceClient::kBoundariesInvalidation);
resource->NotifyContentChanged(SVGResourceClient::kPaintInvalidation |
SVGResourceClient::kFilterCacheInvalidation);
}
}
......
......@@ -26,6 +26,9 @@ class CORE_EXPORT SVGResourceClient : public GarbageCollectedMixin {
kLayoutInvalidation = 1 << 0,
kBoundariesInvalidation = 1 << 1,
kPaintInvalidation = 1 << 2,
kPaintPropertiesInvalidation = 1 << 3,
kClipCacheInvalidation = 1 << 4,
kFilterCacheInvalidation = 1 << 5,
};
virtual void ResourceContentChanged(InvalidationModeMask) = 0;
virtual void ResourceElementChanged() = 0;
......@@ -34,7 +37,7 @@ class CORE_EXPORT SVGResourceClient : public GarbageCollectedMixin {
virtual void FilterPrimitiveChanged(
SVGFilterPrimitiveStandardAttributes& primitive,
const QualifiedName& attribute) {
ResourceContentChanged(kPaintInvalidation);
ResourceContentChanged(kPaintInvalidation | kFilterCacheInvalidation);
}
protected:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment