[gtk+/wip/baedert/gl] snapshot: Directly clip color nodes



commit 904a10821d48381265fc75cd344140a9789855c6
Author: Timm Bäder <mail baedert org>
Date:   Tue Dec 12 20:33:53 2017 +0100

    snapshot: Directly clip color nodes
    
    Clipping a color node is trivial so we do it here directly since that
    might later save the entire clip node as well as freeing the fragment
    shaders from coloring lots of pixels that will be clipped away.

 gtk/gtksnapshot.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c
index d632ef6..d20ee38 100644
--- a/gtk/gtksnapshot.c
+++ b/gtk/gtksnapshot.c
@@ -1340,12 +1340,25 @@ gtk_snapshot_append_color (GtkSnapshot           *snapshot,
   const GtkSnapshotState *current_state = gtk_snapshot_get_current_state (snapshot);
   GskRenderNode *node;
   graphene_rect_t real_bounds;
+  cairo_rectangle_int_t clip_extents;
 
   g_return_if_fail (snapshot != NULL);
   g_return_if_fail (color != NULL);
   g_return_if_fail (bounds != NULL);
 
+  cairo_region_get_extents (gtk_snapshot_get_current_state (snapshot)->clip_region, &clip_extents);
+
   graphene_rect_offset_r (bounds, current_state->translate_x, current_state->translate_y, &real_bounds);
+
+  /* Color nodes are trivially "clippable" so we do it now */
+  graphene_rect_intersection (&GRAPHENE_RECT_INIT (
+                                clip_extents.x,
+                                clip_extents.y,
+                                clip_extents.width,
+                                clip_extents.height
+                              ),
+                              &real_bounds, &real_bounds);
+
   node = gsk_color_node_new (color, &real_bounds);
 
   if (name && snapshot->record_names)


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