[gtk/ngl-tweaks: 2/3] ngl: Skip outset shadows when possible




commit cac3a50856d3a6a33c4571e311327d55570aca2c
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Mar 9 21:18:43 2021 -0500

    ngl: Skip outset shadows when possible
    
    If the current clip is entirely contained in
    the outline of an outset shadow, we don't need
    to draw anything.

 gsk/ngl/gsknglrenderjob.c | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)
---
diff --git a/gsk/ngl/gsknglrenderjob.c b/gsk/ngl/gsknglrenderjob.c
index 6263676584..794086c4e3 100644
--- a/gsk/ngl/gsknglrenderjob.c
+++ b/gsk/ngl/gsknglrenderjob.c
@@ -3706,10 +3706,26 @@ gsk_ngl_render_job_visit_node (GskNglRenderJob     *job,
     break;
 
     case GSK_OUTSET_SHADOW_NODE:
-      if (gsk_outset_shadow_node_get_blur_radius (node) > 0)
-        gsk_ngl_render_job_visit_blurred_outset_shadow_node (job, node);
-      else
-        gsk_ngl_render_job_visit_unblurred_outset_shadow_node (job, node);
+      {
+        const GskRoundedRect *outline = gsk_outset_shadow_node_get_outline (node);
+        GskRoundedRect transformed_outline;
+
+        gsk_ngl_render_job_transform_bounds (job, &outline->bounds, &transformed_outline.bounds);
+
+        for (guint i = 0; i < G_N_ELEMENTS (transformed_outline.corner); i++)
+          {
+            transformed_outline.corner[i].width = outline->corner[i].width * job->scale_x;
+            transformed_outline.corner[i].height = outline->corner[i].height * job->scale_y;
+          }
+
+        if (!gsk_rounded_rect_contains_rect (&transformed_outline, &job->current_clip->rect.bounds))
+          {
+            if (gsk_outset_shadow_node_get_blur_radius (node) > 0)
+              gsk_ngl_render_job_visit_blurred_outset_shadow_node (job, node);
+            else
+              gsk_ngl_render_job_visit_unblurred_outset_shadow_node (job, node);
+          }
+      }
     break;
 
     case GSK_RADIAL_GRADIENT_NODE:


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