Blit the new overlay in one shot if it entirely covers the old one

This commit is contained in:
Cameron Gutman
2026-01-11 12:28:22 -06:00
parent 2549efc8b3
commit 75adc22d05
@@ -1444,7 +1444,13 @@ void DrmRenderer::blitOverlayToCompositionSurface(Overlay::OverlayType type, SDL
SDL_Rect overlayUnionRect;
SDL_UnionRect(overlayRect, &m_OverlayRects[type], &overlayUnionRect);
// If the new overlay completely covers the old overlay, blit it all at once
if (SDL_RectEquals(&overlayUnionRect, overlayRect)) {
SDL_BlitSurface(newSurface, nullptr, m_OverlayCompositionSurface, overlayRect);
}
else {
// Draw the surface row-by-row to ensure we clear the dirty area from the previous surface
// without causing flickering, which would be noticeable if we cleared the whole area first.
for (int y = overlayUnionRect.y; y < overlayUnionRect.y + overlayUnionRect.h; y++) {
auto dstPixelRow =
(uint8_t*)m_OverlayCompositionSurface->pixels +
@@ -1478,6 +1484,7 @@ void DrmRenderer::blitOverlayToCompositionSurface(Overlay::OverlayType type, SDL
(overlayUnionRect.w - overlayRect->w) * bpp);
}
}
}
// Dirty the modified portion of the plane
m_PropSetter.damagePlane(m_OverlayPlanes[0], overlayUnionRect);