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



commit 20dbc5e08ac0de95e3d0c03f05486d02f158fe24
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.

 clutter/clutter/cogl/clutter-stage-cogl.c | 43 ++++++++++++++++++-------------
 1 file changed, 25 insertions(+), 18 deletions(-)
---
diff --git a/clutter/clutter/cogl/clutter-stage-cogl.c b/clutter/clutter/cogl/clutter-stage-cogl.c
index 3c7727b0e..4fce6ea55 100644
--- a/clutter/clutter/cogl/clutter-stage-cogl.c
+++ b/clutter/clutter/cogl/clutter-stage-cogl.c
@@ -855,8 +855,6 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window,
         }
     }
 
-  cairo_region_get_extents (fb_clip_region, &clip_rect);
-
   cogl_push_framebuffer (fb);
   if (use_clipped_redraw && clip_region_empty)
     {
@@ -866,25 +864,34 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window,
     {
       cairo_rectangle_int_t scissor_rect;
 
-      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);
+      if (cairo_region_num_rectangles (fb_clip_region) == 1)
+        {
+          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);
+
+          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]