static GtkSnapshotState *
gtk_snapshot_push_state (GtkSnapshot *snapshot,
char *name,
- const graphene_rect_t *clip,
int translate_x,
int translate_y,
GtkSnapshotCollectFunc collect_func)
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;
static GtkSnapshot *
gtk_snapshot_new_internal (gboolean record_names,
- const graphene_rect_t *clip,
char *name)
{
GtkSnapshot *snapshot;
gtk_snapshot_push_state (snapshot,
name,
- clip,
0, 0,
gtk_snapshot_collect_default);
str = NULL;
return gtk_snapshot_new_internal (record_names,
- NULL,
str);
}
const char *name,
...)
{
- GtkSnapshotState *parent_state;
GtkSnapshot *snapshot;
- graphene_rect_t c, *clip;
char *str;
if (name && parent->record_names)
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;
/**
* 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
*
gtk_snapshot_push_state (snapshot,
g_strdup (str),
- state->has_clip ? &state->clip : NULL,
state->translate_x,
state->translate_y,
gtk_snapshot_collect_default);
{
gtk_snapshot_push_state (snapshot,
g_strdup (str),
- NULL, 0, 0,
+ 0, 0,
gtk_snapshot_collect_default);
}
}
state = gtk_snapshot_push_state (snapshot,
str,
- NULL,
0, 0,
gtk_snapshot_collect_transform);
{
GtkSnapshotState *state = gtk_snapshot_get_current_state (snapshot);
char *str;
- graphene_rect_t clip;
if (snapshot->record_names)
{
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);
}
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);
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);
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);
state = gtk_snapshot_push_state (snapshot,
str,
- &real_child_bounds,
current_state->translate_x,
current_state->translate_y,
gtk_snapshot_collect_repeat);
{
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;
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);
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);
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);
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);
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);
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);
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);
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);
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)
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)
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
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,
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,