mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-12 21:40:19 +00:00
roundedclip: Implement get_opaque_rect
This takes both the vertical and horizontal rectangle that isn't covering the rounded corners and intersects both with the child's opaque rect. And then it returns the larger of the two. This means the small slices of a window near the left/right (or top/bottom) will never be covered, but if we wanted that, we'd need to use something else than a rectangle - either a region or actually a rounded rect. But that is a lot more expensive to implement.
This commit is contained in:
parent
1014b3d972
commit
355a88d002
@ -4621,6 +4621,39 @@ gsk_rounded_clip_node_diff (GskRenderNode *node1,
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gsk_rounded_clip_node_get_opaque_rect (GskRenderNode *node,
|
||||
graphene_rect_t *opaque)
|
||||
{
|
||||
GskRoundedClipNode *self = (GskRoundedClipNode *) node;
|
||||
graphene_rect_t child_opaque, wide_opaque, high_opaque;
|
||||
double start, end;
|
||||
|
||||
if (!gsk_render_node_get_opaque_rect (self->child, &child_opaque))
|
||||
return FALSE;
|
||||
|
||||
wide_opaque = self->clip.bounds;
|
||||
start = MAX(self->clip.corner[GSK_CORNER_TOP_LEFT].height, self->clip.corner[GSK_CORNER_TOP_RIGHT].height);
|
||||
end = MAX(self->clip.corner[GSK_CORNER_BOTTOM_LEFT].height, self->clip.corner[GSK_CORNER_BOTTOM_RIGHT].height);
|
||||
wide_opaque.size.height -= MIN (wide_opaque.size.height, start + end);
|
||||
wide_opaque.origin.y += start;
|
||||
graphene_rect_intersection (&wide_opaque, &child_opaque, &wide_opaque);
|
||||
|
||||
high_opaque = self->clip.bounds;
|
||||
start = MAX(self->clip.corner[GSK_CORNER_TOP_LEFT].width, self->clip.corner[GSK_CORNER_BOTTOM_LEFT].width);
|
||||
end = MAX(self->clip.corner[GSK_CORNER_TOP_RIGHT].width, self->clip.corner[GSK_CORNER_BOTTOM_RIGHT].width);
|
||||
high_opaque.size.width -= MIN (high_opaque.size.width, start + end);
|
||||
high_opaque.origin.x += start;
|
||||
graphene_rect_intersection (&high_opaque, &child_opaque, &high_opaque);
|
||||
|
||||
if (wide_opaque.size.width * wide_opaque.size.height > high_opaque.size.width * high_opaque.size.height)
|
||||
*opaque = wide_opaque;
|
||||
else
|
||||
*opaque = high_opaque;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_rounded_clip_node_class_init (gpointer g_class,
|
||||
gpointer class_data)
|
||||
@ -4632,6 +4665,7 @@ gsk_rounded_clip_node_class_init (gpointer g_class,
|
||||
node_class->finalize = gsk_rounded_clip_node_finalize;
|
||||
node_class->draw = gsk_rounded_clip_node_draw;
|
||||
node_class->diff = gsk_rounded_clip_node_diff;
|
||||
node_class->get_opaque_rect = gsk_rounded_clip_node_get_opaque_rect;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user