diff --git a/gtk/gskpango.c b/gtk/gskpango.c index 7c2aa4dee3..1a25920ca2 100644 --- a/gtk/gskpango.c +++ b/gtk/gskpango.c @@ -132,9 +132,6 @@ gsk_pango_renderer_show_text_glyphs (PangoRenderer *renderer, ink_rect.x + ink_rect.width, ink_rect.height); - if (gtk_snapshot_clips_rect (crenderer->snapshot, &node_bounds)) - return; - gtk_snapshot_get_offset (crenderer->snapshot, &x_offset, &y_offset); graphene_rect_offset (&node_bounds, x_offset, y_offset); diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c index 264d7197a4..012da29f45 100644 --- a/gtk/gtkiconview.c +++ b/gtk/gtkiconview.c @@ -1693,7 +1693,7 @@ gtk_icon_view_snapshot (GtkWidget *widget, item->cell_area.width + icon_view->priv->item_padding * 2, item->cell_area.height + icon_view->priv->item_padding * 2); - if (!gtk_snapshot_clips_rect (snapshot, &area)) + if (gdk_rectangle_intersect (&item->cell_area, &(GdkRectangle) { 0, 0, width, height }, NULL)) { gtk_icon_view_snapshot_item (icon_view, snapshot, item, item->cell_area.x, item->cell_area.y, diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c index 0166660e90..77ada0f484 100644 --- a/gtk/gtksnapshot.c +++ b/gtk/gtksnapshot.c @@ -111,7 +111,6 @@ gtk_snapshot_collect_default (GtkSnapshot *snapshot, static GtkSnapshotState * gtk_snapshot_push_state (GtkSnapshot *snapshot, char *name, - const graphene_rect_t *clip, int translate_x, int translate_y, GtkSnapshotCollectFunc collect_func) @@ -119,12 +118,6 @@ gtk_snapshot_push_state (GtkSnapshot *snapshot, GtkSnapshotState state = { 0, }; state.name = name; - if (clip) - { - state.clip = *clip; - state.has_clip = TRUE; - } - state.translate_x = translate_x; state.translate_y = translate_y; state.collect_func = collect_func; @@ -160,7 +153,6 @@ gtk_snapshot_state_clear (GtkSnapshotState *state) static GtkSnapshot * gtk_snapshot_new_internal (gboolean record_names, - const graphene_rect_t *clip, char *name) { GtkSnapshot *snapshot; @@ -174,7 +166,6 @@ gtk_snapshot_new_internal (gboolean record_names, gtk_snapshot_push_state (snapshot, name, - clip, 0, 0, gtk_snapshot_collect_default); @@ -210,7 +201,6 @@ gtk_snapshot_new (gboolean record_names, str = NULL; return gtk_snapshot_new_internal (record_names, - NULL, str); } @@ -219,9 +209,7 @@ gtk_snapshot_new_child (GtkSnapshot *parent, const char *name, ...) { - GtkSnapshotState *parent_state; GtkSnapshot *snapshot; - graphene_rect_t c, *clip; char *str; if (name && parent->record_names) @@ -235,20 +223,7 @@ gtk_snapshot_new_child (GtkSnapshot *parent, else str = NULL; - parent_state = gtk_snapshot_get_current_state (parent); - if (parent_state->has_clip) - { - graphene_rect_offset_r (&parent_state->clip, - - parent_state->translate_x, - - parent_state->translate_y, - &c); - clip = &c; - } - else - clip = NULL; - snapshot = gtk_snapshot_new_internal (parent->record_names, - clip, str); return snapshot; @@ -300,9 +275,8 @@ gtk_snapshot_free_to_paintable (GtkSnapshot *snapshot, /** * gtk_snapshot_push: * @snapshot: a #GtkSnapshot - * @keep_coordinates: If %TRUE, the current offset and clip will be kept. - * Otherwise, the clip will be unset and the offset will be reset to - * (0, 0). + * @keep_coordinates: If %TRUE, the current offset will be kept. + * Otherwise, the offset will be reset to (0, 0). * @name: (transfer none): a printf() style format string for the name for the new node * @...: arguments to insert into the format string * @@ -334,7 +308,6 @@ gtk_snapshot_push (GtkSnapshot *snapshot, gtk_snapshot_push_state (snapshot, g_strdup (str), - state->has_clip ? &state->clip : NULL, state->translate_x, state->translate_y, gtk_snapshot_collect_default); @@ -344,7 +317,7 @@ gtk_snapshot_push (GtkSnapshot *snapshot, { gtk_snapshot_push_state (snapshot, g_strdup (str), - NULL, 0, 0, + 0, 0, gtk_snapshot_collect_default); } } @@ -395,7 +368,6 @@ gtk_snapshot_push_transform (GtkSnapshot *snapshot, state = gtk_snapshot_push_state (snapshot, str, - NULL, 0, 0, gtk_snapshot_collect_transform); @@ -459,7 +431,6 @@ gtk_snapshot_push_offset (GtkSnapshot *snapshot) { GtkSnapshotState *state = gtk_snapshot_get_current_state (snapshot); char *str; - graphene_rect_t clip; if (snapshot->record_names) { @@ -468,15 +439,8 @@ gtk_snapshot_push_offset (GtkSnapshot *snapshot) else str = NULL; - if (state->has_clip) - graphene_rect_offset_r (&state->clip, - - state->translate_x, - - state->translate_y, - &clip); - state = gtk_snapshot_push_state (snapshot, str, - state->has_clip ? &clip : NULL, 0, 0, gtk_snapshot_collect_offset); } @@ -537,7 +501,6 @@ gtk_snapshot_push_opacity (GtkSnapshot *snapshot, state = gtk_snapshot_push_state (snapshot, str, - current_state->has_clip ? ¤t_state->clip : NULL, current_state->translate_x, current_state->translate_y, gtk_snapshot_collect_opacity); @@ -595,7 +558,6 @@ gtk_snapshot_push_blur (GtkSnapshot *snapshot, state = gtk_snapshot_push_state (snapshot, str, - current_state->has_clip ? ¤t_state->clip : NULL, current_state->translate_x, current_state->translate_y, gtk_snapshot_collect_blur); @@ -682,7 +644,6 @@ gtk_snapshot_push_color_matrix (GtkSnapshot *snapshot, state = gtk_snapshot_push_state (snapshot, str, - current_state->has_clip ? ¤t_state->clip : NULL, current_state->translate_x, current_state->translate_y, gtk_snapshot_collect_color_matrix); @@ -756,7 +717,6 @@ gtk_snapshot_push_repeat (GtkSnapshot *snapshot, state = gtk_snapshot_push_state (snapshot, str, - &real_child_bounds, current_state->translate_x, current_state->translate_y, gtk_snapshot_collect_repeat); @@ -807,7 +767,7 @@ gtk_snapshot_push_clip (GtkSnapshot *snapshot, { const GtkSnapshotState *current_state = gtk_snapshot_get_current_state (snapshot); GtkSnapshotState *state; - graphene_rect_t clip, real_bounds; + graphene_rect_t real_bounds; cairo_rectangle_int_t rect; char *str; @@ -825,14 +785,9 @@ gtk_snapshot_push_clip (GtkSnapshot *snapshot, str = NULL; rectangle_init_from_graphene (&rect, &real_bounds); - if (current_state->has_clip) - graphene_rect_intersection (¤t_state->clip, &real_bounds, &clip); - else - clip = real_bounds; state = gtk_snapshot_push_state (snapshot, str, - &clip, current_state->translate_x, current_state->translate_y, gtk_snapshot_collect_clip); @@ -895,7 +850,6 @@ gtk_snapshot_push_rounded_clip (GtkSnapshot *snapshot, const GtkSnapshotState *current_state = gtk_snapshot_get_current_state (snapshot); GtkSnapshotState *state; GskRoundedRect real_bounds; - graphene_rect_t clip; char *str; gsk_rounded_rect_init_copy (&real_bounds, bounds); @@ -912,14 +866,8 @@ gtk_snapshot_push_rounded_clip (GtkSnapshot *snapshot, else str = NULL; - if (current_state->has_clip) - graphene_rect_intersection (¤t_state->clip, &real_bounds.bounds, &clip); - else - clip = real_bounds.bounds; - state = gtk_snapshot_push_state (snapshot, str, - &clip, current_state->translate_x, current_state->translate_y, gtk_snapshot_collect_rounded_clip); @@ -979,7 +927,6 @@ gtk_snapshot_push_shadow (GtkSnapshot *snapshot, state = gtk_snapshot_push_state (snapshot, str, - current_state->has_clip ? ¤t_state->clip : NULL, current_state->translate_x, current_state->translate_y, gtk_snapshot_collect_shadow); @@ -1082,7 +1029,6 @@ gtk_snapshot_push_blend (GtkSnapshot *snapshot, top_state = gtk_snapshot_push_state (snapshot, str, - current_state->has_clip ? ¤t_state->clip : NULL, current_state->translate_x, current_state->translate_y, gtk_snapshot_collect_blend_top); @@ -1090,7 +1036,6 @@ gtk_snapshot_push_blend (GtkSnapshot *snapshot, gtk_snapshot_push_state (snapshot, g_strdup (str), - top_state->has_clip ? &top_state->clip : NULL, top_state->translate_x, top_state->translate_y, gtk_snapshot_collect_blend_bottom); @@ -1207,7 +1152,6 @@ gtk_snapshot_push_cross_fade (GtkSnapshot *snapshot, end_state = gtk_snapshot_push_state (snapshot, str, - current_state->has_clip ? ¤t_state->clip : NULL, current_state->translate_x, current_state->translate_y, gtk_snapshot_collect_cross_fade_end); @@ -1215,7 +1159,6 @@ gtk_snapshot_push_cross_fade (GtkSnapshot *snapshot, gtk_snapshot_push_state (snapshot, g_strdup (str), - end_state->has_clip ? &end_state->clip : NULL, end_state->translate_x, end_state->translate_y, gtk_snapshot_collect_cross_fade_start); @@ -1486,9 +1429,6 @@ gtk_snapshot_append_cairo (GtkSnapshot *snapshot, graphene_rect_offset_r (bounds, current_state->translate_x, current_state->translate_y, &real_bounds); - if (current_state->has_clip) - graphene_rect_intersection (¤t_state->clip, &real_bounds, &real_bounds); - node = gsk_cairo_node_new (&real_bounds); if (name && snapshot->record_names) @@ -1593,10 +1533,6 @@ gtk_snapshot_append_color (GtkSnapshot *snapshot, 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 */ - if (current_state->has_clip) - graphene_rect_intersection (¤t_state->clip, &real_bounds, &real_bounds); - node = gsk_color_node_new (color, &real_bounds); if (name && snapshot->record_names) @@ -1617,50 +1553,6 @@ gtk_snapshot_append_color (GtkSnapshot *snapshot, gsk_render_node_unref (node); } -gboolean -gtk_snapshot_get_clip (GtkSnapshot *snapshot, - graphene_rect_t *out_clip) -{ - const GtkSnapshotState *current_state = gtk_snapshot_get_current_state (snapshot); - - if (!current_state->has_clip) - return FALSE; - - graphene_rect_offset_r (¤t_state->clip, - - current_state->translate_x, - - current_state->translate_y, - out_clip); - - return TRUE; -} - -/** - * gtk_snapshot_clips_rect: - * @snapshot: a #GtkSnapshot - * @bounds: a rectangle - * - * Tests whether the rectangle is entirely outside the clip region of @snapshot. - * - * Returns: %TRUE if @bounds is entirely outside the clip region - */ -gboolean -gtk_snapshot_clips_rect (GtkSnapshot *snapshot, - const graphene_rect_t *bounds) -{ - const GtkSnapshotState *current_state = gtk_snapshot_get_current_state (snapshot); - graphene_rect_t offset_rect; - - if (!current_state->has_clip) - return FALSE; - - graphene_rect_offset_r (bounds, - current_state->translate_x, - current_state->translate_y, - &offset_rect); - - return !graphene_rect_intersection (&offset_rect, ¤t_state->clip, NULL); -} - /** * gtk_snapshot_render_background: * @snapshot: a #GtkSnapshot @@ -1835,10 +1727,6 @@ gtk_snapshot_append_linear_gradient (GtkSnapshot *snapshot, real_end_point.x = end_point->x + current_state->translate_x; real_end_point.y = end_point->y + current_state->translate_y; - /* Linear gradients can be trivially clipped if we don't change the start/end points. */ - if (current_state->has_clip) - graphene_rect_intersection (¤t_state->clip, &real_bounds, &real_bounds); - node = gsk_linear_gradient_node_new (&real_bounds, &real_start_point, &real_end_point, @@ -1902,10 +1790,6 @@ gtk_snapshot_append_repeating_linear_gradient (GtkSnapshot *snapshot, real_end_point.x = end_point->x + current_state->translate_x; real_end_point.y = end_point->y + current_state->translate_y; - /* Repeating Linear gradients can be trivially clipped if we don't change the start/end points. */ - if (current_state->has_clip) - graphene_rect_intersection (¤t_state->clip, &real_bounds, &real_bounds); - node = gsk_repeating_linear_gradient_node_new (&real_bounds, &real_start_point, &real_end_point, diff --git a/gtk/gtksnapshot.h b/gtk/gtksnapshot.h index 7647a6b092..577994c1b6 100644 --- a/gtk/gtksnapshot.h +++ b/gtk/gtksnapshot.h @@ -169,10 +169,6 @@ void gtk_snapshot_append_layout (GtkSnapshot ...) G_GNUC_PRINTF (4, 5); -GDK_AVAILABLE_IN_ALL -gboolean gtk_snapshot_clips_rect (GtkSnapshot *snapshot, - const graphene_rect_t *bounds); - GDK_AVAILABLE_IN_ALL void gtk_snapshot_render_background (GtkSnapshot *snapshot, GtkStyleContext *context, diff --git a/gtk/gtksnapshotprivate.h b/gtk/gtksnapshotprivate.h index 6e34d17c22..ba134b779e 100644 --- a/gtk/gtksnapshotprivate.h +++ b/gtk/gtksnapshotprivate.h @@ -35,12 +35,9 @@ struct _GtkSnapshotState { guint start_node_index; guint n_nodes; - graphene_rect_t clip; int translate_x; int translate_y; - guint has_clip : 1; - GtkSnapshotCollectFunc collect_func; union { struct { @@ -104,8 +101,6 @@ GtkSnapshot * gtk_snapshot_new_child (GtkSnapshot ...) G_GNUC_PRINTF (2, 3); void gtk_snapshot_append_node_internal (GtkSnapshot *snapshot, GskRenderNode *node); -gboolean gtk_snapshot_get_clip (GtkSnapshot *snapshot, - graphene_rect_t *out_clip); G_END_DECLS diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 745caa0afd..0a23cd8c81 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -3910,7 +3910,6 @@ gtk_widget_queue_draw (GtkWidget *widget) priv->draw_needed = TRUE; g_clear_pointer (&priv->render_node, gsk_render_node_unref); - priv->render_node_has_clip = FALSE; gtk_widget_invalidate_paintable_contents (widget); if (_gtk_widget_get_has_surface (widget) && _gtk_widget_get_realized (widget)) @@ -13287,8 +13286,6 @@ gtk_widget_snapshot (GtkWidget *widget, GtkSnapshot *snapshot) { GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget); - graphene_rect_t clip; - gboolean has_clip; double opacity; if (!_gtk_widget_is_drawable (widget)) @@ -13304,10 +13301,7 @@ gtk_widget_snapshot (GtkWidget *widget, if (opacity <= 0.0) return; - has_clip = gtk_snapshot_get_clip (snapshot, &clip); - - if (priv->draw_needed || - (priv->render_node_has_clip && (!has_clip || !graphene_rect_contains_rect (&priv->render_node_clip, &clip)))) + if (priv->draw_needed) { GskRenderNode *render_node; @@ -13316,15 +13310,6 @@ gtk_widget_snapshot (GtkWidget *widget, * or when we replace a clipped area */ g_clear_pointer (&priv->render_node, gsk_render_node_unref); priv->render_node = render_node; - if (has_clip) - { - priv->render_node_clip = clip; - priv->render_node_has_clip = TRUE; - } - else - { - priv->render_node_has_clip = FALSE; - } priv->draw_needed = FALSE; } diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h index a4d15c63ad..7b76ffa2bf 100644 --- a/gtk/gtkwidgetprivate.h +++ b/gtk/gtkwidgetprivate.h @@ -78,8 +78,6 @@ struct _GtkWidgetPrivate /* Queue-draw related flags */ guint draw_needed : 1; - guint render_node_has_clip : 1; - /* Expand-related flags */ guint need_compute_expand : 1; /* Need to recompute computed_[hv]_expand */ guint computed_hexpand : 1; /* computed results (composite of child flags) */ @@ -146,9 +144,6 @@ struct _GtkWidgetPrivate /* The render node we draw or %NULL if not yet created.*/ GskRenderNode *render_node; - /* The clip that existed when the render node was drawn - * Ignored when render_node_has_clip == FALSE */ - graphene_rect_t render_node_clip; GSList *paintables;