subsurface: Fully covered backgrounds don't need to be drawn

If the texture covers all of the black background (like when watching a
1080p stream fullscreen on a 1080p monitor) we don't need a compositor
with single pixel support.

Fixes offloading in Kwin.
This commit is contained in:
Benjamin Otte 2024-08-14 08:06:13 +02:00
parent a7b69ad9b5
commit 8c6e5ca131

View File

@ -167,6 +167,12 @@ gdk_subsurface_attach (GdkSubsurface *subsurface,
g_return_val_if_fail (sibling == NULL || GDK_IS_SUBSURFACE (sibling), FALSE);
g_return_val_if_fail (sibling == NULL || sibling->parent == subsurface->parent, FALSE);
/* if the texture fully covers the background, ignore it */
if (background &&
gsk_rect_contains_rect (dest, background) &&
gdk_memory_format_alpha (gdk_texture_get_format (texture)) == GDK_MEMORY_ALPHA_OPAQUE)
background = NULL;
result = GDK_SUBSURFACE_GET_CLASS (subsurface)->attach (subsurface,
texture,
source,