static void cb_compose_images_snapshot (GtkWidget *widget, GtkSnapshot *snapshot) { const int width = gtk_widget_get_width (widget); const int height = gtk_widget_get_height (widget); /* This is only relevant when an image gets transitioned to being deleted, * but we just always push a clip node here, for simplicity. */ gtk_snapshot_push_clip (snapshot, &GRAPHENE_RECT_INIT (0, 0, width, height), "ComposeImagesClip"); GTK_WIDGET_CLASS (cb_compose_images_parent_class)->snapshot (widget, snapshot); gtk_snapshot_pop (snapshot); }
/* This is the function that draws the puzzle piece. * It just draws a rectangular cutout of the puzzle by clipping * away the rest. */ static void gtk_puzzle_piece_snapshot (GdkPaintable *paintable, GdkSnapshot *snapshot, double width, double height) { GtkPuzzlePiece *self = GTK_PUZZLE_PIECE (paintable); gtk_snapshot_push_clip (snapshot, &GRAPHENE_RECT_INIT (0, 0, width, height)); gtk_snapshot_offset (snapshot, - width * self->x, - height * self->y); gdk_paintable_snapshot (self->puzzle, snapshot, width * self->width, height * self->height); gtk_snapshot_pop (snapshot); }
static void gtk_render_node_paintable_paintable_snapshot (GdkPaintable *paintable, GdkSnapshot *snapshot, double width, double height) { GtkRenderNodePaintable *self = GTK_RENDER_NODE_PAINTABLE (paintable); gboolean needs_transform; needs_transform = self->bounds.size.width != width || self->bounds.size.height != height; if (needs_transform) { graphene_matrix_t transform; graphene_matrix_init_scale (&transform, width / (self->bounds.size.width), height / (self->bounds.size.height), 1.0); gtk_snapshot_push_transform (snapshot, &transform); } gtk_snapshot_offset (snapshot, -self->bounds.origin.x, -self->bounds.origin.y); gtk_snapshot_push_clip (snapshot, &self->bounds); gtk_snapshot_append_node (snapshot, self->node); //gtk_snapshot_append_color (snapshot, &(GdkRGBA) { 1, 0, 0, 1 }, &self->bounds); gtk_snapshot_pop (snapshot); gtk_snapshot_offset (snapshot, self->bounds.origin.x, self->bounds.origin.y); if (needs_transform) gtk_snapshot_pop (snapshot); }