offload: Use gsk_color_node_get_color2

We want the blackest black.
This commit is contained in:
Matthias Clasen 2024-08-04 22:29:44 -04:00
parent d5ae94ca5d
commit 3d3e935c91

View File

@ -69,6 +69,15 @@ find_texture_transform (GskTransform *transform)
return dihedral; return dihedral;
} }
static gboolean
color_is_black (const GdkColor *color)
{
return color->red < 255.f / 65535.f &&
color->green < 255.f / 65535.f &&
color->blue < 255.f / 65535.f &&
color->alpha > 65280.f / 65535.f;
}
static GdkTexture * static GdkTexture *
find_texture_to_attach (GskOffload *self, find_texture_to_attach (GskOffload *self,
const GskRenderNode *subsurface_node, const GskRenderNode *subsurface_node,
@ -116,7 +125,7 @@ find_texture_to_attach (GskOffload *self,
gsk_transform_transform_bounds (transform, &child->bounds, &bounds); gsk_transform_transform_bounds (transform, &child->bounds, &bounds);
if (GSK_RENDER_NODE_TYPE (child) == GSK_COLOR_NODE && if (GSK_RENDER_NODE_TYPE (child) == GSK_COLOR_NODE &&
gsk_rect_equal (&bounds, &subsurface_node->bounds) && gsk_rect_equal (&bounds, &subsurface_node->bounds) &&
gdk_rgba_equal (gsk_color_node_get_color (child), &GDK_RGBA_BLACK)) color_is_black (gsk_color_node_get_color2 (child)))
{ {
*has_background = TRUE; *has_background = TRUE;
node = gsk_container_node_get_child (node, 1); node = gsk_container_node_get_child (node, 1);