gsk: Add gsk_render_node_get_opaque_rect()

Gets a rectangle inside the rendernode that is opaque.

This function only adds the API. So far, no implementation exists.
This commit is contained in:
Benjamin Otte 2023-04-03 14:52:00 +02:00
parent 5a59548d72
commit 9c032bec89
3 changed files with 51 additions and 8 deletions

View File

@ -160,6 +160,13 @@ gsk_render_node_real_diff (GskRenderNode *node1,
gsk_render_node_diff_impossible (node1, node2, data);
}
static gboolean
gsk_render_node_real_get_opaque_rect (GskRenderNode *node,
graphene_rect_t *out_opaque)
{
return FALSE;
}
static void
gsk_render_node_class_init (GskRenderNodeClass *klass)
{
@ -167,6 +174,7 @@ gsk_render_node_class_init (GskRenderNodeClass *klass)
klass->finalize = gsk_render_node_finalize;
klass->can_diff = gsk_render_node_real_can_diff;
klass->diff = gsk_render_node_real_diff;
klass->get_opaque_rect = gsk_render_node_real_get_opaque_rect;
}
static void
@ -559,6 +567,35 @@ gsk_render_node_diff (GskRenderNode *node1,
}
}
/**
* gsk_render_node_get_opaque_rect:
* @self: a `GskRenderNode`
* @out_opaque: (out):
*
* Gets an opaque rectangle inside the node that GTK can determine to
* be fully opaque.
*
* There is no guarantee that this is indeed the largest opaque rectangle or
* that regions outside the rectangle are not opaque. This function is a best
* effort with that goal.
*
* The rectangle will be fully contained in the bounds of the node.
*
* Returns: %TRUE if part or all of the rendernode is opaque, %FALSE if no
* opaque region could be found.
*
* Since: 4.16
**/
gboolean
gsk_render_node_get_opaque_rect (GskRenderNode *self,
graphene_rect_t *out_opaque)
{
g_return_val_if_fail (GSK_IS_RENDER_NODE (self), FALSE);
g_return_val_if_fail (out_opaque != NULL, FALSE);
return GSK_RENDER_NODE_GET_CLASS (self)->get_opaque_rect (self, out_opaque);
}
/**
* gsk_render_node_write_to_file:
* @node: a `GskRenderNode`

View File

@ -122,6 +122,10 @@ GDK_AVAILABLE_IN_ALL
void gsk_render_node_get_bounds (GskRenderNode *node,
graphene_rect_t *bounds);
GDK_AVAILABLE_IN_4_16
gboolean gsk_render_node_get_opaque_rect (GskRenderNode *self,
graphene_rect_t *out_opaque);
GDK_AVAILABLE_IN_ALL
void gsk_render_node_draw (GskRenderNode *node,
cairo_t *cr);

View File

@ -56,6 +56,8 @@ struct _GskRenderNodeClass
void (* diff) (GskRenderNode *node1,
GskRenderNode *node2,
GskDiffData *data);
gboolean (* get_opaque_rect) (GskRenderNode *node,
graphene_rect_t *out_opaque);
};
void gsk_render_node_init_types (void);