From 30bc8bc6ce079a69cc933d9fe0a2d5a928be3b81 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Sun, 29 Apr 2012 04:44:53 -0400 Subject: [PATCH] window-actor: Add a debugging tool to write a region to a PNG Just a helper function that I keep rewriting all over the place. https://bugzilla.gnome.org/show_bug.cgi?id=676052 --- src/compositor/meta-window-actor.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/compositor/meta-window-actor.c b/src/compositor/meta-window-actor.c index fb5b0c887..d7c889142 100644 --- a/src/compositor/meta-window-actor.c +++ b/src/compositor/meta-window-actor.c @@ -1684,7 +1684,7 @@ meta_window_actor_get_obscured_region (MetaWindowActor *self) #if 0 /* Print out a region; useful for debugging */ static void -dump_region (cairo_region_t *region) +print_region (cairo_region_t *region) { int n_rects; int i; @@ -1702,6 +1702,26 @@ dump_region (cairo_region_t *region) } #endif +#if 0 +/* Dump a region to a PNG file; useful for debugging */ +static void +see_region (cairo_region_t *region, + int width, + int height, + char *filename) +{ + cairo_surface_t *surface = cairo_image_surface_create (CAIRO_FORMAT_A8, width, height); + cairo_t *cr = cairo_create (surface); + + gdk_cairo_region (cr, region); + cairo_fill (cr); + + cairo_surface_write_to_png (surface, filename); + cairo_destroy (cr); + cairo_surface_destroy (surface); +} +#endif + /** * meta_window_actor_set_visible_region: * @self: a #MetaWindowActor