[cairo-commit] 3 commits - src/cairo-compositor.c src/cairo-damage.c src/win32

Chris Wilson ickle at kemper.freedesktop.org
Wed Mar 21 13:18:33 PDT 2012


 src/cairo-compositor.c                  |   35 ++++++++++++++++++++++----
 src/cairo-damage.c                      |   18 ++++++++++++-
 src/win32/cairo-win32-display-surface.c |   42 +++++++++++++++++++++++---------
 src/win32/cairo-win32-gdi-compositor.c  |    5 ++-
 4 files changed, 80 insertions(+), 20 deletions(-)

New commits:
commit 9bb5b02694e1bbd5c0cdd28606d80fb2d2d701ee
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Mar 21 20:08:15 2012 +0000

    win32: Fix damage flushing
    
    The damage wasn't being created on the right surface, so the damage to
    the fallback image surface was not being tracked. Perform a little bit
    of juggling so that we track dirty regions on the fallback surface itself.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/win32/cairo-win32-display-surface.c b/src/win32/cairo-win32-display-surface.c
index 9e18f8d..a66a23e 100644
--- a/src/win32/cairo-win32-display-surface.c
+++ b/src/win32/cairo-win32-display-surface.c
@@ -460,9 +460,6 @@ _cairo_win32_display_surface_map_to_image (void                    *abstract_sur
     }
 
     surface = to_win32_display_surface (surface->fallback);
-    if (surface->image->damage == NULL)
-	surface->image->damage = _cairo_damage_create ();
-
 done:
     GdiFlush();
     return _cairo_image_surface_map_to_image (surface->image, extents);
@@ -475,14 +472,31 @@ err:
 }
 
 static cairo_int_status_t
-_cairo_win32_display_surface_unmap_image (void                    *surface,
+_cairo_win32_display_surface_unmap_image (void                    *abstract_surface,
 					  cairo_image_surface_t   *image)
 {
+    cairo_win32_display_surface_t *surface = abstract_surface;
+
     /* Delay the download until the next flush, which means we also need
      * to make sure our sources rare flushed.
      */
     TRACE ((stderr, "%s (surface=%d)\n",
 	    __FUNCTION__, to_win32_surface(surface)->base.unique_id));
+
+    if (surface->fallback) {
+	cairo_rectangle_int_t r;
+
+	r.x = image->base.device_transform_inverse.x0;
+	r.y = image->base.device_transform_inverse.y0;
+	r.width  = image->width;
+	r.height = image->height;
+
+	TRACE ((stderr, "%s: adding damage (%d,%d)x(%d,%d)\n",
+		__FUNCTION__, r.x, r.y, r.width, r.height));
+	surface->fallback->damage =
+	    _cairo_damage_add_rectangle (surface->fallback->damage, &r);
+    }
+
     return CAIRO_INT_STATUS_SUCCESS;
 }
 
@@ -490,7 +504,6 @@ static cairo_status_t
 _cairo_win32_display_surface_flush (void *abstract_surface)
 {
     cairo_win32_display_surface_t *surface = abstract_surface;
-    cairo_win32_display_surface_t *fallback;
     cairo_status_t status = CAIRO_STATUS_SUCCESS;
 
     TRACE ((stderr, "%s (surface=%d)\n",
@@ -498,14 +511,18 @@ _cairo_win32_display_surface_flush (void *abstract_surface)
     if (surface->fallback == NULL)
 	return CAIRO_STATUS_SUCCESS;
 
-    fallback = to_win32_display_surface (surface->fallback);
-    assert (fallback->image);
-
-    if (fallback->image->damage) {
+    if (surface->fallback->damage) {
+	cairo_win32_display_surface_t *fallback;
 	cairo_damage_t *damage;
 
-	damage = _cairo_damage_reduce (fallback->image->damage);
-	fallback->image->damage = NULL;
+	damage = _cairo_damage_reduce (surface->fallback->damage);
+	surface->fallback->damage = NULL;
+
+	fallback = to_win32_display_surface (surface->fallback);
+	assert (fallback->image);
+
+	TRACE ((stderr, "%s: flushing damage x %d\n", __FUNCTION__,
+		damage->region ? cairo_region_num_rectangles (damage->region) : 0));
 
 	if (damage->status) {
 	    if (!BitBlt (surface->win32.dc,
@@ -522,6 +539,9 @@ _cairo_win32_display_surface_flush (void *abstract_surface)
 		cairo_rectangle_int_t rect;
 
 		cairo_region_get_rectangle (damage->region, i, &rect);
+		TRACE ((stderr, "%s: damage (%d,%d)x(%d,%d)\n", __FUNCTION__,
+			rect.x, rect.y,
+			rect.width, rect.height));
 		if (!BitBlt (surface->win32.dc,
 			     rect.x, rect.y,
 			     rect.width, rect.height,
diff --git a/src/win32/cairo-win32-gdi-compositor.c b/src/win32/cairo-win32-gdi-compositor.c
index 054d9f2..2bdac66 100644
--- a/src/win32/cairo-win32-gdi-compositor.c
+++ b/src/win32/cairo-win32-gdi-compositor.c
@@ -343,7 +343,7 @@ alpha_blend_boxes (cairo_win32_display_surface_t *dst,
 	if (surface == NULL)
 	    return CAIRO_INT_STATUS_UNSUPPORTED;
     }
-    if (pattern->surface->type != CAIRO_SURFACE_TYPE_WIN32)
+    if (surface->type != CAIRO_SURFACE_TYPE_WIN32)
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
     if (! _cairo_matrix_is_integer_translation (&source->matrix,
@@ -410,7 +410,8 @@ draw_boxes (cairo_composite_rectangles_t *composite,
 	_cairo_pattern_is_opaque (src, &composite->bounded))
 	op = CAIRO_OPERATOR_SOURCE;
 
-    if (dst->win32.base.is_clear && op == CAIRO_OPERATOR_OVER)
+    if (dst->win32.base.is_clear &&
+	(op == CAIRO_OPERATOR_OVER || op == CAIRO_OPERATOR_ADD))
 	op = CAIRO_OPERATOR_SOURCE;
 
     if (op == CAIRO_OPERATOR_SOURCE) {
commit c504dba5a76def6358a5b309ad5bc4a8dfe6199e
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Mar 21 20:07:00 2012 +0000

    damage: Fix memcpy size
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-damage.c b/src/cairo-damage.c
index 7b95c84..f0a7306 100644
--- a/src/cairo-damage.c
+++ b/src/cairo-damage.c
@@ -85,6 +85,8 @@ _cairo_damage_add_boxes(cairo_damage_t *damage,
     struct _cairo_damage_chunk *chunk;
     int n, size;
 
+    TRACE ((stderr, "%s x%d\n", __FUNCTION__, count));
+
     if (damage == NULL)
 	damage = _cairo_damage_create ();
 
@@ -94,7 +96,8 @@ _cairo_damage_add_boxes(cairo_damage_t *damage,
     if (n > damage->remain)
 	n = damage->remain;
 
-    memcpy (damage->tail->base + damage->tail->count, boxes, n);
+    memcpy (damage->tail->base + damage->tail->count, boxes,
+	    n * sizeof (cairo_box_t));
 
     count -= n;
     damage->tail->count += n;
@@ -121,7 +124,8 @@ _cairo_damage_add_boxes(cairo_damage_t *damage,
     damage->tail->next = chunk;
     damage->remain = size - count;
 
-    memcpy (damage->tail->base, boxes + n, count);
+    memcpy (damage->tail->base, boxes + n,
+	    count * sizeof (cairo_box_t));
 
     return damage;
 }
@@ -130,6 +134,9 @@ cairo_damage_t *
 _cairo_damage_add_box(cairo_damage_t *damage,
 		      const cairo_box_t *box)
 {
+    TRACE ((stderr, "%s: (%d, %d),(%d, %d)\n", __FUNCTION__,
+	    box->p1.x, box->p1.y, box->p2.x, box->p2.y));
+
     return _cairo_damage_add_boxes(damage, box, 1);
 }
 
@@ -139,6 +146,9 @@ _cairo_damage_add_rectangle(cairo_damage_t *damage,
 {
     cairo_box_t box;
 
+    TRACE ((stderr, "%s: (%d, %d)x(%d, %d)\n", __FUNCTION__,
+	    r->x, r->y, r->width, r->height));
+
     box.p1.x = r->x;
     box.p1.y = r->y;
     box.p2.x = r->x + r->width;
@@ -154,6 +164,8 @@ _cairo_damage_add_region (cairo_damage_t *damage,
     cairo_box_t *boxes;
     int nbox;
 
+    TRACE ((stderr, "%s\n", __FUNCTION__));
+
     boxes = _cairo_region_get_boxes (region, &nbox);
     return _cairo_damage_add_boxes(damage, boxes, nbox);
 }
@@ -165,6 +177,8 @@ _cairo_damage_reduce (cairo_damage_t *damage)
     cairo_box_t *boxes, *b;
     struct _cairo_damage_chunk *chunk, *last;
 
+    TRACE ((stderr, "%s: dirty=%d\n", __FUNCTION__,
+	    damage ? damage->dirty : -1));
     if (damage == NULL || !damage->dirty)
 	return damage;
 
commit eafa127001319942e2a5e2009979e3ffd36320ed
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Mar 21 20:07:55 2012 +0000

    compositor: Add tracing for damage
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-compositor.c b/src/cairo-compositor.c
index 56e46ef..a633aa2 100644
--- a/src/cairo-compositor.c
+++ b/src/cairo-compositor.c
@@ -67,9 +67,14 @@ _cairo_compositor_paint (const cairo_compositor_t	*compositor,
 	compositor = compositor->delegate;
     } while (status == CAIRO_INT_STATUS_UNSUPPORTED);
 
-    if (status == CAIRO_INT_STATUS_SUCCESS && surface->damage)
+    if (status == CAIRO_INT_STATUS_SUCCESS && surface->damage) {
+	TRACE ((stderr, "%s: applying damage (%d,%d)x(%d, %d)\n",
+		__FUNCTION__,
+		extents.unbounded.x, extents.unbounded.y,
+		extents.unbounded.width, extents.unbounded.height));
 	surface->damage = _cairo_damage_add_rectangle (surface->damage,
 						       &extents.unbounded);
+    }
 
     _cairo_composite_rectangles_fini (&extents);
 
@@ -103,9 +108,14 @@ _cairo_compositor_mask (const cairo_compositor_t	*compositor,
 	compositor = compositor->delegate;
     } while (status == CAIRO_INT_STATUS_UNSUPPORTED);
 
-    if (status == CAIRO_INT_STATUS_SUCCESS && surface->damage)
+    if (status == CAIRO_INT_STATUS_SUCCESS && surface->damage) {
+	TRACE ((stderr, "%s: applying damage (%d,%d)x(%d, %d)\n",
+		__FUNCTION__,
+		extents.unbounded.x, extents.unbounded.y,
+		extents.unbounded.width, extents.unbounded.height));
 	surface->damage = _cairo_damage_add_rectangle (surface->damage,
 						       &extents.unbounded);
+    }
 
     _cairo_composite_rectangles_fini (&extents);
 
@@ -147,9 +157,14 @@ _cairo_compositor_stroke (const cairo_compositor_t	*compositor,
 	compositor = compositor->delegate;
     } while (status == CAIRO_INT_STATUS_UNSUPPORTED);
 
-    if (status == CAIRO_INT_STATUS_SUCCESS && surface->damage)
+    if (status == CAIRO_INT_STATUS_SUCCESS && surface->damage) {
+	TRACE ((stderr, "%s: applying damage (%d,%d)x(%d, %d)\n",
+		__FUNCTION__,
+		extents.unbounded.x, extents.unbounded.y,
+		extents.unbounded.width, extents.unbounded.height));
 	surface->damage = _cairo_damage_add_rectangle (surface->damage,
 						       &extents.unbounded);
+    }
 
     _cairo_composite_rectangles_fini (&extents);
 
@@ -187,9 +202,14 @@ _cairo_compositor_fill (const cairo_compositor_t	*compositor,
 	compositor = compositor->delegate;
     } while (status == CAIRO_INT_STATUS_UNSUPPORTED);
 
-    if (status == CAIRO_INT_STATUS_SUCCESS && surface->damage)
+    if (status == CAIRO_INT_STATUS_SUCCESS && surface->damage) {
+	TRACE ((stderr, "%s: applying damage (%d,%d)x(%d, %d)\n",
+		__FUNCTION__,
+		extents.unbounded.x, extents.unbounded.y,
+		extents.unbounded.width, extents.unbounded.height));
 	surface->damage = _cairo_damage_add_rectangle (surface->damage,
 						       &extents.unbounded);
+    }
 
     _cairo_composite_rectangles_fini (&extents);
 
@@ -229,9 +249,14 @@ _cairo_compositor_glyphs (const cairo_compositor_t		*compositor,
 	compositor = compositor->delegate;
     } while (status == CAIRO_INT_STATUS_UNSUPPORTED);
 
-    if (status == CAIRO_INT_STATUS_SUCCESS && surface->damage)
+    if (status == CAIRO_INT_STATUS_SUCCESS && surface->damage) {
+	TRACE ((stderr, "%s: applying damage (%d,%d)x(%d, %d)\n",
+		__FUNCTION__,
+		extents.unbounded.x, extents.unbounded.y,
+		extents.unbounded.width, extents.unbounded.height));
 	surface->damage = _cairo_damage_add_rectangle (surface->damage,
 						       &extents.unbounded);
+    }
 
     _cairo_composite_rectangles_fini (&extents);
 


More information about the cairo-commit mailing list