From d7ec5d3022613bcce0366a5ae4ee53ba0c581175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 28 Feb 2019 22:48:46 +0100 Subject: [PATCH] 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 --- src/backends/meta-stage.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/backends/meta-stage.c b/src/backends/meta-stage.c index c009f1022..f536fc23a 100644 --- a/src/backends/meta-stage.c +++ b/src/backends/meta-stage.c @@ -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 *