Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 9cc587ef6ae8f7e1ddc0d47cda5de2564d295728
https://github.com/WebKit/WebKit/commit/9cc587ef6ae8f7e1ddc0d47cda5de2564d295728
Author: Nikolas Zimmermann <[email protected]>
Date: 2026-07-14 (Tue, 14 Jul 2026)
Changed paths:
M Source/WebCore/platform/graphics/Damage.h
M Tools/TestWebKitAPI/Tests/WebCore/glib/Damage.cpp
Log Message:
-----------
[Damage] Add rectsForPainting() and fix uniting two damages that share a grid
https://bugs.webkit.org/show_bug.cgi?id=319360
Reviewed by Carlos Garcia Campos.
Add Damage::rectsForPainting(), which returns rects that never overlap, unlike
rects(), and that never outnumber the damage grid's cells. A caller that draws
each rect separately needs both: overlapping rects would composite translucent
content twice, and an unbounded rect count would turn one draw into arbitrarily
many. Overlapping rects are split at the cell borders and united per cell, which
leaves at most one rect per cell. Rects that overlap nothing are left whole,
because splitting them would only make more work for the caller that draws them.
Also fix add(const Damage&). Its fast path for two damages that are already
united
onto the same grid unites the per-cell rects, but leaves the indices that
iteration
walks unset and the bounding rectangle stale, so a cell damaged in the other
damage
but not yet here is stored and then never returned by rects(). It was
unreachable
until now, because no two damages shared a grid.
The new API has no callers yet. Cover it with an API test.
* Source/WebCore/platform/graphics/Damage.h:
(WebCore::Damage::rectsForPainting const):
(WebCore::Damage::add):
(WebCore::Damage::hasOverlappingRects):
* Tools/TestWebKitAPI/Tests/WebCore/glib/Damage.cpp:
(TestWebKitAPI::TEST(Damage, RectsForPainting)):
Canonical link: https://commits.webkit.org/317137@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications