[mutter/wip/carlosg/clip-regions: 8/12] clutter/cogl: Use regions for clipping if necessary



commit c49e291625b41c1bdfd75850164c4c87a5c5c731
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Jul 30 23:50:22 2019 +0200

    clutter/cogl: Use regions for clipping if necessary
    
    Use the new cogl function to perform clipping if the clip area
    consists of more than a single rectangle.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/867

 clutter/clutter/cogl/clutter-stage-cogl.c | 41 ++++++++++++++++++-------------
 1 file changed, 24 insertions(+), 17 deletions(-)
---
diff --git a/clutter/clutter/cogl/clutter-stage-cogl.c b/clutter/clutter/cogl/clutter-stage-cogl.c
index 751f26da3..cf9a94159 100644
--- a/clutter/clutter/cogl/clutter-stage-cogl.c
+++ b/clutter/clutter/cogl/clutter-stage-cogl.c
@@ -883,27 +883,34 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window,
       cairo_rectangle_int_t clip_rect;
       cairo_rectangle_int_t scissor_rect;
 
-      cairo_region_get_extents (fb_clip_region, &clip_rect);
+      stage_cogl->using_clipped_redraw = TRUE;
 
-      calculate_scissor_region (&clip_rect,
-                                subpixel_compensation,
-                                fb_width, fb_height,
-                                &scissor_rect);
+      if (cairo_region_num_rectangles (fb_clip_region) == 1)
+        {
+          cairo_region_get_extents (fb_clip_region, &clip_rect);
 
-      CLUTTER_NOTE (CLIPPING,
-                    "Stage clip pushed: x=%d, y=%d, width=%d, height=%d\n",
-                    scissor_rect.x,
-                    scissor_rect.y,
-                    scissor_rect.width,
-                    scissor_rect.height);
+          calculate_scissor_region (&clip_rect,
+                                    subpixel_compensation,
+                                    fb_width, fb_height,
+                                    &scissor_rect);
 
-      stage_cogl->using_clipped_redraw = TRUE;
+          CLUTTER_NOTE (CLIPPING,
+                        "Stage clip pushed: x=%d, y=%d, width=%d, height=%d\n",
+                        scissor_rect.x,
+                        scissor_rect.y,
+                        scissor_rect.width,
+                        scissor_rect.height);
 
-      cogl_framebuffer_push_scissor_clip (fb,
-                                          scissor_rect.x,
-                                          scissor_rect.y,
-                                          scissor_rect.width,
-                                          scissor_rect.height);
+          cogl_framebuffer_push_scissor_clip (fb,
+                                              scissor_rect.x,
+                                              scissor_rect.y,
+                                              scissor_rect.width,
+                                              scissor_rect.height);
+        }
+      else
+        {
+          cogl_framebuffer_push_region_clip (fb, fb_clip_region);
+        }
 
       paint_stage (stage_cogl, view, fb_clip_region);
 


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