mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-18 22:50:57 +00:00
Blit the new overlay in one shot if it entirely covers the old one
This commit is contained in:
@@ -1444,38 +1444,45 @@ void DrmRenderer::blitOverlayToCompositionSurface(Overlay::OverlayType type, SDL
|
|||||||
SDL_Rect overlayUnionRect;
|
SDL_Rect overlayUnionRect;
|
||||||
SDL_UnionRect(overlayRect, &m_OverlayRects[type], &overlayUnionRect);
|
SDL_UnionRect(overlayRect, &m_OverlayRects[type], &overlayUnionRect);
|
||||||
|
|
||||||
// Draw the surface row-by-row to ensure we clear the dirty area from the previous surface
|
// If the new overlay completely covers the old overlay, blit it all at once
|
||||||
for (int y = overlayUnionRect.y; y < overlayUnionRect.y + overlayUnionRect.h; y++) {
|
if (SDL_RectEquals(&overlayUnionRect, overlayRect)) {
|
||||||
auto dstPixelRow =
|
SDL_BlitSurface(newSurface, nullptr, m_OverlayCompositionSurface, overlayRect);
|
||||||
(uint8_t*)m_OverlayCompositionSurface->pixels +
|
}
|
||||||
(y * m_OverlayCompositionSurface->pitch);
|
else {
|
||||||
auto bpp = m_OverlayCompositionSurface->format->BytesPerPixel;
|
// 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 +
|
||||||
|
(y * m_OverlayCompositionSurface->pitch);
|
||||||
|
auto bpp = m_OverlayCompositionSurface->format->BytesPerPixel;
|
||||||
|
|
||||||
if (y < overlayRect->y || y > overlayRect->y + overlayRect->h) {
|
if (y < overlayRect->y || y > overlayRect->y + overlayRect->h) {
|
||||||
// Clear the whole row if the overlay doesn't intersect this row
|
// Clear the whole row if the overlay doesn't intersect this row
|
||||||
memset(dstPixelRow + (overlayUnionRect.x * bpp),
|
memset(dstPixelRow + (overlayUnionRect.x * bpp),
|
||||||
0,
|
0,
|
||||||
overlayUnionRect.w * bpp);
|
overlayUnionRect.w * bpp);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
auto srcPixelRow = (uint8_t*)newSurface->pixels + ((y - overlayRect->y) * newSurface->pitch);
|
auto srcPixelRow = (uint8_t*)newSurface->pixels + ((y - overlayRect->y) * newSurface->pitch);
|
||||||
|
|
||||||
// Clear columns prior to the intersection
|
// Clear columns prior to the intersection
|
||||||
SDL_assert(overlayRect->x >= overlayUnionRect.x);
|
SDL_assert(overlayRect->x >= overlayUnionRect.x);
|
||||||
memset(dstPixelRow + (overlayUnionRect.x * bpp),
|
memset(dstPixelRow + (overlayUnionRect.x * bpp),
|
||||||
0,
|
0,
|
||||||
(overlayRect->x - overlayUnionRect.x) * bpp);
|
(overlayRect->x - overlayUnionRect.x) * bpp);
|
||||||
|
|
||||||
// Copy the overlay into the intersection
|
// Copy the overlay into the intersection
|
||||||
memcpy(dstPixelRow + (overlayRect->x * bpp),
|
memcpy(dstPixelRow + (overlayRect->x * bpp),
|
||||||
srcPixelRow,
|
srcPixelRow,
|
||||||
overlayRect->w * bpp);
|
overlayRect->w * bpp);
|
||||||
|
|
||||||
// Clear columns after the intersection
|
// Clear columns after the intersection
|
||||||
SDL_assert(overlayUnionRect.w >= overlayRect->w);
|
SDL_assert(overlayUnionRect.w >= overlayRect->w);
|
||||||
memset(dstPixelRow + ((overlayRect->x + overlayRect->w) * bpp),
|
memset(dstPixelRow + ((overlayRect->x + overlayRect->w) * bpp),
|
||||||
0,
|
0,
|
||||||
(overlayUnionRect.w - overlayRect->w) * bpp);
|
(overlayUnionRect.w - overlayRect->w) * bpp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user