Merge branch 'wip/otte/for-main' into 'main'

renderer: Remove priv->root_node

See merge request GNOME/gtk!6565
This commit is contained in:
Benjamin Otte 2023-11-14 14:43:47 +00:00
commit 160f632668
3 changed files with 71 additions and 54 deletions

View File

@ -87,8 +87,6 @@ params_buffer_failed (void *data,
{
CreateBufferData *cd = data;
GDK_DEBUG (OFFLOAD, "Creating wl_buffer for dmabuf failed");
cd->buffer = NULL;
cd->done = TRUE;
}
@ -198,12 +196,23 @@ gdk_wayland_subsurface_attach (GdkSubsurface *sub,
0, 0,
gdk_texture_get_width (texture),
gdk_texture_get_height (texture));
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
"Attached %dx%d texture to subsurface %p at %d %d %d %d",
gdk_texture_get_width (texture),
gdk_texture_get_height (texture),
self,
self->dest.x, self->dest.y,
self->dest.width, self->dest.height);
result = TRUE;
}
else
{
GDK_DISPLAY_DEBUG (gdk_surface_get_display (sub->parent), OFFLOAD,
"Failed to get buffer for texture, hiding subsurface %p", self);
"Failed to create wl_buffer for %dx%d texture, hiding subsurface %p",
gdk_texture_get_width (texture),
gdk_texture_get_height (texture),
self);
g_set_object (&self->texture, NULL);

View File

@ -57,34 +57,55 @@ struct _GskOffload
};
static GdkTexture *
find_texture_to_attach (const GskRenderNode *node)
find_texture_to_attach (GskOffload *self,
GdkSubsurface *subsurface,
const GskRenderNode *node)
{
switch ((int)GSK_RENDER_NODE_TYPE (node))
for (;;)
{
case GSK_DEBUG_NODE:
return find_texture_to_attach (gsk_debug_node_get_child (node));
switch ((int)GSK_RENDER_NODE_TYPE (node))
{
case GSK_DEBUG_NODE:
node = gsk_debug_node_get_child (node);
break;
case GSK_CONTAINER_NODE:
if (gsk_container_node_get_n_children (node) == 1)
return find_texture_to_attach (gsk_container_node_get_child (node, 0));
break;
case GSK_CONTAINER_NODE:
if (gsk_container_node_get_n_children (node) != 1)
{
GDK_DISPLAY_DEBUG (gdk_surface_get_display (self->surface), OFFLOAD,
"Can't offload subsurface %p: too much content, container with %d children",
subsurface, gsk_container_node_get_n_children (node));
return NULL;
}
node = gsk_container_node_get_child (node, 0);
break;
case GSK_TRANSFORM_NODE:
{
GskTransform *t = gsk_transform_node_get_transform (node);
if (gsk_transform_get_category (t) >= GSK_TRANSFORM_CATEGORY_2D_AFFINE)
return find_texture_to_attach (gsk_transform_node_get_child (node));
}
break;
case GSK_TRANSFORM_NODE:
{
GskTransform *t = gsk_transform_node_get_transform (node);
if (gsk_transform_get_category (t) < GSK_TRANSFORM_CATEGORY_2D_AFFINE)
{
char *s = gsk_transform_to_string (t);
GDK_DISPLAY_DEBUG (gdk_surface_get_display (self->surface), OFFLOAD,
"Can't offload subsurface %p: transform %s is not just scale/translate",
subsurface, s);
g_free (s);
return NULL;
}
node = gsk_transform_node_get_child (node);
}
break;
case GSK_TEXTURE_NODE:
return gsk_texture_node_get_texture (node);
case GSK_TEXTURE_NODE:
return gsk_texture_node_get_texture (node);
default:
break;
default:
GDK_DISPLAY_DEBUG (gdk_surface_get_display (self->surface), OFFLOAD,
"Can't offload subsurface %p: Only textures supported but found %s",
subsurface, g_type_name_from_instance ((GTypeInstance *) node));
return NULL;
}
}
return NULL;
}
static void
@ -502,26 +523,29 @@ complex_clip:
GskOffloadInfo *info = find_subsurface_info (self, subsurface);
if (info)
if (info == NULL)
{
info->texture = find_texture_to_attach (gsk_subsurface_node_get_child (node));
info->can_offload = self->current_clip->is_fully_contained &&
info->texture != NULL;
if (info->can_offload)
GDK_DISPLAY_DEBUG (gdk_surface_get_display (self->surface), OFFLOAD,
"Can't offload: unknown subsurface %p",
subsurface);
}
else if (!self->current_clip->is_fully_contained)
{
GDK_DISPLAY_DEBUG (gdk_surface_get_display (self->surface), OFFLOAD,
"Can't offload subsurface %p: clipped",
subsurface);
}
else
{
info->texture = find_texture_to_attach (self, subsurface, gsk_subsurface_node_get_child (node));
if (info->texture)
{
info->can_offload = TRUE;
transform_bounds (self, &node->bounds, &info->rect);
info->place_above = self->last_info ? self->last_info->subsurface : NULL;
self->last_info = info;
self->can_raise = TRUE;
}
else
{
GDK_DISPLAY_DEBUG (gdk_surface_get_display (self->surface), OFFLOAD,
"Can't offload subsurface %p: %s",
subsurface,
info->texture == NULL ? "no texture" : "clipped");
}
}
}
break;
@ -580,13 +604,6 @@ gsk_offload_new (GdkSurface *surface,
if (info->can_offload)
{
GDK_DISPLAY_DEBUG (display, OFFLOAD, "Attaching %dx%d texture to subsurface %p at %g %g %g %g",
gdk_texture_get_width (info->texture),
gdk_texture_get_height (info->texture),
info->subsurface,
info->rect.origin.x, info->rect.origin.y,
info->rect.size.width, info->rect.size.height);
info->is_offloaded = gdk_subsurface_attach (info->subsurface,
info->texture,
&info->rect);

View File

@ -78,7 +78,6 @@ typedef struct
GdkSurface *surface;
GskRenderNode *prev_node;
GskRenderNode *root_node;
GskProfiler *profiler;
@ -365,9 +364,6 @@ gsk_renderer_render_texture (GskRenderer *renderer,
g_return_val_if_fail (GSK_IS_RENDERER (renderer), NULL);
g_return_val_if_fail (priv->is_realized, NULL);
g_return_val_if_fail (GSK_IS_RENDER_NODE (root), NULL);
g_return_val_if_fail (priv->root_node == NULL, NULL);
priv->root_node = gsk_render_node_ref (root);
if (viewport == NULL)
{
@ -394,8 +390,6 @@ gsk_renderer_render_texture (GskRenderer *renderer,
g_string_free (buf, TRUE);
}
g_clear_pointer (&priv->root_node, gsk_render_node_unref);
return texture;
}
@ -432,13 +426,11 @@ gsk_renderer_render (GskRenderer *renderer,
g_return_if_fail (GSK_IS_RENDERER (renderer));
g_return_if_fail (priv->is_realized);
g_return_if_fail (GSK_IS_RENDER_NODE (root));
g_return_if_fail (priv->root_node == NULL);
if (priv->surface == NULL)
return;
renderer_class = GSK_RENDERER_GET_CLASS (renderer);
priv->root_node = gsk_render_node_ref (root);
if (renderer_class->supports_offload &&
!GSK_RENDERER_DEBUG_CHECK (renderer, OFFLOAD_DISABLE))
@ -481,8 +473,7 @@ gsk_renderer_render (GskRenderer *renderer,
g_clear_pointer (&priv->prev_node, gsk_render_node_unref);
cairo_region_destroy (clip);
g_clear_pointer (&offload, gsk_offload_free);
priv->prev_node = priv->root_node;
priv->root_node = NULL;
priv->prev_node = gsk_render_node_ref (root);
}
/*< private >