/** * gtk_snapshot_append_color_node: * @snapshot: a #GtkSnapshot * @color: the #GdkRGBA to draw * @bounds: the bounds for the new node * @name: (transfer none): a printf() style format string for the name for the new node * @...: arguments to insert into the format string * * Creates a new render node drawing the @color into the given @bounds and appends it * to the current render node of @snapshot. * * You should try to avoid calling this function if @color is transparent. **/ void gtk_snapshot_append_color_node (GtkSnapshot *snapshot, const GdkRGBA *color, const graphene_rect_t *bounds, const char *name, ...) { GskRenderNode *node; graphene_rect_t real_bounds; g_return_if_fail (snapshot != NULL); g_return_if_fail (color != NULL); g_return_if_fail (bounds != NULL); graphene_rect_offset_r (bounds, snapshot->state->translate_x, snapshot->state->translate_y, &real_bounds); node = gsk_color_node_new (color, &real_bounds); if (name) { va_list args; char *str; va_start (args, name); str = g_strdup_vprintf (name, args); va_end (args); gsk_render_node_set_name (node, str); g_free (str); } gtk_snapshot_append_node (snapshot, node); gsk_render_node_unref (node); }
/** * graphene_rect_offset: * @r: a #graphene_rect_t * @d_x: the horizontal offset * @d_y: the vertical offset * * Offsets the origin by @d_x and @d_y. * * The size of the rectangle is unchanged. * * Returns: (transfer none): the offset rectangle * * Since: 1.0 */ graphene_rect_t * graphene_rect_offset (graphene_rect_t *r, float d_x, float d_y) { graphene_rect_offset_r (r, d_x, d_y, r); return r; }
/** * gtk_snapshot_clips_rect: * @snapshot: a #GtkSnapshot * @bounds: a rectangle * * Tests whether the rectangle is entirely outside the clip region of @snapshot. * * Returns: %TRUE is @bounds is entirely outside the clip region * * Since: 3.90 */ gboolean gtk_snapshot_clips_rect (GtkSnapshot *snapshot, const graphene_rect_t *bounds) { graphene_rect_t offset_bounds; cairo_rectangle_int_t rect; if (snapshot->state->clip_region == NULL) return FALSE; graphene_rect_offset_r (bounds, snapshot->state->translate_x, snapshot->state->translate_y, &offset_bounds); rectangle_init_from_graphene (&rect, &offset_bounds); return cairo_region_contains_rectangle (snapshot->state->clip_region, &rect) == CAIRO_REGION_OVERLAP_OUT; }
void gtk_snapshot_push_clip (GtkSnapshot *snapshot, const graphene_rect_t *bounds, const char *name, ...) { graphene_rect_t *real_bounds; cairo_region_t *clip; cairo_rectangle_int_t rect; char *str; real_bounds = g_slice_new (graphene_rect_t); graphene_rect_offset_r (bounds, snapshot->state->translate_x, snapshot->state->translate_y, real_bounds); if (name) { va_list args; va_start (args, name); str = g_strdup_vprintf (name, args); va_end (args); } else str = NULL; rectangle_init_from_graphene (&rect, real_bounds); if (snapshot->state->clip_region) { clip = cairo_region_copy (snapshot->state->clip_region); cairo_region_intersect_rectangle (clip, &rect); } else { clip = cairo_region_create_rectangle (&rect); } snapshot->state = gtk_snapshot_state_new (snapshot->state, str, clip, snapshot->state->translate_x, snapshot->state->translate_y, gtk_snapshot_collect_clip, real_bounds); cairo_region_destroy (clip); }
/** * gtk_snapshot_append_cairo_node: * @snapshot: a #GtkSnapshot * @bounds: the bounds for the new node * @name: (transfer none): a printf() style format string for the name for the new node * @...: arguments to insert into the format string * * Creates a new render node and appends it to the current render * node of @snapshot, without changing the current node. * * Returns: a cairo_t suitable for drawing the contents of the newly * created render node * * Since: 3.90 */ cairo_t * gtk_snapshot_append_cairo_node (GtkSnapshot *snapshot, const graphene_rect_t *bounds, const char *name, ...) { GskRenderNode *node; graphene_rect_t real_bounds; cairo_t *cr; g_return_val_if_fail (snapshot != NULL, NULL); g_return_val_if_fail (bounds != NULL, NULL); graphene_rect_offset_r (bounds, snapshot->state->translate_x, snapshot->state->translate_y, &real_bounds); node = gsk_cairo_node_new (&real_bounds); if (name) { va_list args; char *str; va_start (args, name); str = g_strdup_vprintf (name, args); va_end (args); gsk_render_node_set_name (node, str); g_free (str); } gtk_snapshot_append_node (snapshot, node); gsk_render_node_unref (node); cr = gsk_cairo_node_get_draw_context (node, snapshot->renderer); cairo_translate (cr, snapshot->state->translate_x, snapshot->state->translate_y); return cr; }