[vte/rendering-cleanup] Use cairo_copy_clip_rectangle_list() to recreate the clip region
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte/rendering-cleanup] Use cairo_copy_clip_rectangle_list() to recreate the clip region
- Date: Mon, 13 Sep 2010 20:58:15 +0000 (UTC)
commit ea5d64cf38f0c0f97a53ce63fca45d46dd2b2384
Author: Christian Persch <chpe gnome org>
Date: Mon Sep 13 21:44:50 2010 +0200
Use cairo_copy_clip_rectangle_list() to recreate the clip region
Thanks to Behdad for the hint, and for pointing out a bug in my
first attempt.
src/vte.c | 48 ++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 44 insertions(+), 4 deletions(-)
---
diff --git a/src/vte.c b/src/vte.c
index 74187f8..2156c52 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -10888,6 +10888,46 @@ vte_terminal_paint(GtkWidget *widget, GdkRegion *region)
/* Handle an expose event by painting the exposed area. */
#if GTK_CHECK_VERSION (2, 90, 8)
+static cairo_region_t *
+vte_cairo_get_clip_region (cairo_t *cr)
+{
+ cairo_rectangle_list_t *list;
+ cairo_region_t *region;
+ int i;
+
+ list = cairo_copy_clip_rectangle_list (cr);
+ if (list->status == CAIRO_STATUS_CLIP_NOT_REPRESENTABLE) {
+ cairo_rectangle_int_t clip_rect;
+
+ cairo_rectangle_list_destroy (list);
+
+ if (!gdk_cairo_get_clip_rectangle (cr, &clip_rect))
+ return NULL;
+ return cairo_region_create_rectangle (&clip_rect);
+ }
+
+
+ region = cairo_region_create ();
+ for (i = list->num_rectangles - 1; i >= 0; --i) {
+ cairo_rectangle_t *rect = &list->rectangles[i];
+ cairo_rectangle_int_t clip_rect;
+
+ clip_rect.x = floor (rect->x);
+ clip_rect.y = floor (rect->y);
+ clip_rect.width = ceil (rect->x + rect->width) - clip_rect.x;
+ clip_rect.height = ceil (rect->y + rect->height) - clip_rect.y;
+
+ if (cairo_region_union_rectangle (region, &clip_rect) != CAIRO_STATUS_SUCCESS) {
+ cairo_region_destroy (region);
+ region = NULL;
+ break;
+ }
+ }
+
+ cairo_rectangle_list_destroy (list);
+ return region;
+}
+
static gboolean
vte_terminal_draw(GtkWidget *widget,
cairo_t *cr,
@@ -10906,10 +10946,10 @@ vte_terminal_draw(GtkWidget *widget,
clip_rect.x, clip_rect.y,
clip_rect.width, clip_rect.height);
- /* Sucks that we don't have the expose region available; the clip rect
- * is potentially much much larger.
- */
- region = cairo_region_create_rectangle (&clip_rect);
+ region = vte_cairo_get_clip_region (cr);
+ if (region == NULL)
+ return FALSE;
+
vte_terminal_paint(widget, region);
cairo_region_destroy (region);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]