diff --git a/gsk/gskrendernode.c b/gsk/gskrendernode.c index b2a2c8fff6..4eff329575 100644 --- a/gsk/gskrendernode.c +++ b/gsk/gskrendernode.c @@ -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` diff --git a/gsk/gskrendernode.h b/gsk/gskrendernode.h index 7c0d4a3d49..d688984a9e 100644 --- a/gsk/gskrendernode.h +++ b/gsk/gskrendernode.h @@ -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); diff --git a/gsk/gskrendernodeprivate.h b/gsk/gskrendernodeprivate.h index 4d794b1094..fe2bcbf462 100644 --- a/gsk/gskrendernodeprivate.h +++ b/gsk/gskrendernodeprivate.h @@ -48,14 +48,16 @@ struct _GskRenderNodeClass GskRenderNodeType node_type; - void (* finalize) (GskRenderNode *node); - void (* draw) (GskRenderNode *node, - cairo_t *cr); - gboolean (* can_diff) (const GskRenderNode *node1, - const GskRenderNode *node2); - void (* diff) (GskRenderNode *node1, - GskRenderNode *node2, - GskDiffData *data); + void (* finalize) (GskRenderNode *node); + void (* draw) (GskRenderNode *node, + cairo_t *cr); + gboolean (* can_diff) (const GskRenderNode *node1, + const GskRenderNode *node2); + 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);