stage: Add utility function to queue draw a ClutterRect

Remove duplicated code to clamp to pixel

https://gitlab.gnome.org/GNOME/mutter/merge_requests/3
This commit is contained in:
Marco Trevisan (Treviño) 2019-02-28 22:48:46 +01:00 committed by Marco Trevisan
parent 7442de81bb
commit d7ec5d3022

View File

@ -213,32 +213,35 @@ meta_stage_new (void)
NULL);
}
static void
queue_redraw_clutter_rect (MetaStage *stage,
MetaOverlay *overlay,
ClutterRect *rect)
{
cairo_rectangle_int_t clip = {
.x = floorf (rect->origin.x),
.y = floorf (rect->origin.y),
.width = ceilf (rect->size.width),
.height = ceilf (rect->size.height)
};
clutter_actor_queue_redraw_with_clip (CLUTTER_ACTOR (stage), &clip);
}
static void
queue_redraw_for_overlay (MetaStage *stage,
MetaOverlay *overlay)
{
cairo_rectangle_int_t clip;
/* Clear the location the overlay was at before, if we need to. */
if (overlay->previous_is_valid)
{
clip.x = floorf (overlay->previous_rect.origin.x),
clip.y = floorf (overlay->previous_rect.origin.y),
clip.width = ceilf (overlay->previous_rect.size.width),
clip.height = ceilf (overlay->previous_rect.size.height),
clutter_actor_queue_redraw_with_clip (CLUTTER_ACTOR (stage), &clip);
queue_redraw_clutter_rect (stage, overlay, &overlay->previous_rect);
overlay->previous_is_valid = FALSE;
}
/* Draw the overlay at the new position */
if (overlay->enabled)
{
clip.x = floorf (overlay->current_rect.origin.x),
clip.y = floorf (overlay->current_rect.origin.y),
clip.width = ceilf (overlay->current_rect.size.width),
clip.height = ceilf (overlay->current_rect.size.height),
clutter_actor_queue_redraw_with_clip (CLUTTER_ACTOR (stage), &clip);
}
queue_redraw_clutter_rect (stage, overlay, &overlay->current_rect);
}
MetaOverlay *