[mutter] stage: Add utility function to queue draw a ClutterRect



commit d7ec5d3022613bcce0366a5ae4ee53ba0c581175
Author: Marco Trevisan (Treviño) <mail 3v1n0 net>
Date:   Thu Feb 28 22:48:46 2019 +0100

    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 *


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]