Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 48a050966d899df1be64b7b2d1860267742769cf
      
https://github.com/WebKit/WebKit/commit/48a050966d899df1be64b7b2d1860267742769cf
  Author: Nikolas Zimmermann <[email protected]>
  Date:   2026-07-17 (Fri, 17 Jul 2026)

  Changed paths:
    M Source/WebCore/platform/graphics/skia/SkiaCompositingLayer.cpp
    M Source/WebCore/platform/graphics/skia/SkiaCompositingLayer.h
    M Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp
    M Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h
    M 
Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/AcceleratedSurface.cpp
    M Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/AcceleratedSurface.h
    M Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp
    M 
Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCompositor.cpp
    M Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCompositor.h

  Log Message:
  -----------
  [Damage][Skia] Composite only the damage
https://bugs.webkit.org/show_bug.cgi?id=315990

Reviewed by Alejandro G. Castro.

Wire the pieces together and start painting from the damage, if the feature
'UseDamagingInformationForCompositing' is turned on (not yet on by default).

Each frame's damage is recorded for the platform and into every swap-chain 
target,
and the target, the frame is drawn into, brings its own record of what changed 
since
it was last current. The two together are the region the frame is painted 
against:
everything when there is no record or it covers the surface, nothing when the 
target
already holds the frame, and otherwise the clear and every draw are limited to 
its rects.

paint() collects and draws in one call, so the compositor reads the target's 
record
before painting and passes it as priorTargetDamage, to be folded there with this
frame's freshly collected damage. Recording into the swap chain happens after 
paint()
returns, which is the same as recording before it, since paint() only reads the 
target
it draws into.

Debug borders and repaint counters are painted by the layer tree, but their 
setters
stored the new state without damaging, unlike every other layer setter. Nothing
repainted them when they appeared or changed, and the frame that switched them 
off
reported no damage for them at all, so they stayed on the targets. They now 
damage the
layer like any other state change, on both the Skia and the TextureMapper side, 
which
is what lets a frame stay restricted to its damage while they show.

The FPS counter is drawn on top of the layer tree, so no layer damages it 
either, but
it is a fixed box in the corner rather than something that can be anywhere. It 
damages
its own box on the frames the count changes, together with the box drawn 
before, which
is larger when the count gets shorter. Its geometry therefore has to be 
computed before
the frame is painted rather than while it is drawn. A counter that repainted 
more than
its box would hide the cost it is there to measure - so we need to avoid that.

The damage visualizer and the overlay below cannot do the same, because they 
draw over
the damage itself: damaging what they drew would feed their own rects back into 
what
they show next, until it covers the surface. They repaint the frame in full 
instead,
and the platform is told the whole surface changed - that's okay, since it's 
debug-only.

WEBKIT_SHOW_DAMAGE keeps its name on the Skia path, so one variable shows the 
damage
whichever compositor is in use. It now draws a target's whole accumulated 
damage as a
translucent green overlay, rather than the frame damage the compositor no 
longer paints
from. Since it repaints in full, it shows what the damage is, not the compositor
honouring it.

* Source/WebCore/platform/graphics/skia/SkiaCompositingLayer.cpp:
(WebCore::SkiaCompositingLayer::paintedLayerRect const):
(WebCore::SkiaCompositingLayer::setDebugIndicators):
(WebCore::SkiaCompositingLayer::paint):
* Source/WebCore/platform/graphics/skia/SkiaCompositingLayer.h:
* Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp:
(WebCore::TextureMapperLayer::setShowDebugBorder):
(WebCore::TextureMapperLayer::setDebugBorderColor):
(WebCore::TextureMapperLayer::setDebugBorderWidth):
(WebCore::TextureMapperLayer::setShowRepaintCounter):
(WebCore::TextureMapperLayer::setRepaintCount):
* Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h:
(WebCore::TextureMapperLayer::setShowDebugBorder): Deleted.
(WebCore::TextureMapperLayer::setDebugBorderColor): Deleted.
(WebCore::TextureMapperLayer::setDebugBorderWidth): Deleted.
(WebCore::TextureMapperLayer::setShowRepaintCounter): Deleted.
(WebCore::TextureMapperLayer::setRepaintCount): Deleted.
* Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/AcceleratedSurface.cpp:
(WebKit::AcceleratedSurface::SwapChainDamageTracker::didPresent):
(WebKit::AcceleratedSurface::backgroundColor):
(WebKit::AcceleratedSurface::skiaClearColor):
(WebKit::AcceleratedSurface::clear):
(WebKit::clearCanvas): Deleted.
* Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/AcceleratedSurface.h:
* Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp:
(WebKit::damageOverlayForcesPropagation):
(WebKit::LayerTreeHost::LayerTreeHost):
(WebKit::LayerTreeHost::attachLayer):
* Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCompositor.cpp:
(WebKit::m_renderTimer):
(WebKit::ThreadedCompositor::setDamagePropagationSettings):
(WebKit::ThreadedCompositor::damageUsedForCompositing const):
(WebKit::ThreadedCompositor::drawsOverlay const):
(WebKit::ThreadedCompositor::paintToCurrentGLContext):
(WebKit::ThreadedCompositor::paintToTextureMapper):
(WebKit::ThreadedCompositor::recordFrameDamage):
(WebKit::drawDamageOverlay):
(WebKit::ThreadedCompositor::paintToSkiaCanvas):
(WebKit::ThreadedCompositor::renderLayerTree):
(WebKit::fpsCounterFont):
(WebKit::fpsCounterPadding):
(WebKit::ThreadedCompositor::fpsCounterRect const):
(WebKit::ThreadedCompositor::updateFPSCounterGeometry):
(WebKit::ThreadedCompositor::takeFPSCounterDamage):
(WebKit::ThreadedCompositor::drawFPSCounter):
(WebKit::ThreadedCompositor::drawSkiaDamage): Deleted.
* Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCompositor.h:

Canonical link: https://commits.webkit.org/317400@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to