[cairo-commit] 4 commits - src/cairo-gstate.c src/cairoint.h src/cairo-polygon.c src/cairo-recording-surface.c src/cairo-spans-compositor.c

Chris Wilson ickle at kemper.freedesktop.org
Wed Oct 12 09:16:25 PDT 2011


 src/cairo-gstate.c            |    1 
 src/cairo-polygon.c           |   44 +++++++++++++++++++++++++++++-------------
 src/cairo-recording-surface.c |   10 +++++++++
 src/cairo-spans-compositor.c  |    3 ++
 src/cairoint.h                |    9 ++++++++
 5 files changed, 54 insertions(+), 13 deletions(-)

New commits:
commit 282cfff15663a0c1ee5f3c8e53745d2c7f47539e
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Oct 12 17:12:09 2011 +0100

    recording-surface: Initialize optimize-clears before use in snapshotting
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-recording-surface.c b/src/cairo-recording-surface.c
index 5f87e6c..5316a10 100644
--- a/src/cairo-recording-surface.c
+++ b/src/cairo-recording-surface.c
@@ -1099,6 +1099,7 @@ _cairo_recording_surface_snapshot (void *abstract_other)
 
     surface->indices = NULL;
     surface->num_indices = 0;
+    surface->optimize_clears = TRUE;
 
     _cairo_array_init (&surface->commands, sizeof (cairo_command_t *));
     status = _cairo_recording_surface_replay (&other->base, &surface->base);
commit f84f6ecaa46d6e6ab1ebdf024fddc46bfacf2c0c
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Oct 12 17:09:12 2011 +0100

    gstate: Prevent leak of old clip when creating a group with translation
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index c37fd8b..d232f9b 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -319,6 +319,7 @@ _cairo_gstate_redirect_target (cairo_gstate_t *gstate, cairo_surface_t *child)
 
     /* The clip is in surface backend coordinates for the previous target;
      * translate it into the child's backend coordinates. */
+    _cairo_clip_destroy (gstate->clip);
     gstate->clip = _cairo_clip_copy_with_translation (gstate->next->clip,
 						      child->device_transform.x0 - gstate->parent_target->device_transform.x0,
 						      child->device_transform.y0 - gstate->parent_target->device_transform.y0);
commit 8f34fa033e741eed040ff8895fcb94b8507903b8
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Oct 12 17:04:16 2011 +0100

    spans: Refresh polygon limits after trimming the composite extents
    
    Trimming the composite extents may result in the clip being
    reconstructed, but we the polygon continued to hold a reference into the
    freed clip's array of boxes. So if we intend to reuse the polygon limits
    after performing the clip we need to refresh them.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-polygon.c b/src/cairo-polygon.c
index a44cba3..90f81f7 100644
--- a/src/cairo-polygon.c
+++ b/src/cairo-polygon.c
@@ -48,24 +48,12 @@ _cairo_polygon_add_edge (cairo_polygon_t *polygon,
 			 int dir);
 
 void
-_cairo_polygon_init (cairo_polygon_t *polygon,
+_cairo_polygon_limit (cairo_polygon_t *polygon,
 		     const cairo_box_t *limits,
 		     int num_limits)
 {
     int n;
 
-    VG (VALGRIND_MAKE_MEM_UNDEFINED (polygon, sizeof (cairo_polygon_t)));
-
-    polygon->status = CAIRO_STATUS_SUCCESS;
-
-    polygon->num_edges = 0;
-
-    polygon->edges = polygon->edges_embedded;
-    polygon->edges_size = ARRAY_LENGTH (polygon->edges_embedded);
-
-    polygon->extents.p1.x = polygon->extents.p1.y = INT32_MAX;
-    polygon->extents.p2.x = polygon->extents.p2.y = INT32_MIN;
-
     polygon->limits = limits;
     polygon->num_limits = num_limits;
 
@@ -88,6 +76,36 @@ _cairo_polygon_init (cairo_polygon_t *polygon,
 }
 
 void
+_cairo_polygon_limit_to_clip (cairo_polygon_t *polygon,
+			      const cairo_clip_t *clip)
+{
+    if (clip)
+	_cairo_polygon_limit (polygon, clip->boxes, clip->num_boxes);
+    else
+	_cairo_polygon_limit (polygon, 0, 0);
+}
+
+void
+_cairo_polygon_init (cairo_polygon_t *polygon,
+		     const cairo_box_t *limits,
+		     int num_limits)
+{
+    VG (VALGRIND_MAKE_MEM_UNDEFINED (polygon, sizeof (cairo_polygon_t)));
+
+    polygon->status = CAIRO_STATUS_SUCCESS;
+
+    polygon->num_edges = 0;
+
+    polygon->edges = polygon->edges_embedded;
+    polygon->edges_size = ARRAY_LENGTH (polygon->edges_embedded);
+
+    polygon->extents.p1.x = polygon->extents.p1.y = INT32_MAX;
+    polygon->extents.p2.x = polygon->extents.p2.y = INT32_MIN;
+
+    _cairo_polygon_limit (polygon, limits, num_limits);
+}
+
+void
 _cairo_polygon_init_with_clip (cairo_polygon_t *polygon,
 			       const cairo_clip_t *clip)
 {
diff --git a/src/cairo-spans-compositor.c b/src/cairo-spans-compositor.c
index a4efa48..468f338 100644
--- a/src/cairo-spans-compositor.c
+++ b/src/cairo-spans-compositor.c
@@ -810,6 +810,9 @@ clip_and_composite_polygon (const cairo_spans_compositor_t	*compositor,
 	    cairo_clip_t *old_clip;
 
 	    if (clip_antialias == antialias) {
+		/* refresh limits after trimming extents */
+		_cairo_polygon_limit_to_clip(polygon, extents->clip);
+
 		status = _cairo_polygon_intersect (polygon, fill_rule,
 						   &clipper, clip_fill_rule);
 		_cairo_polygon_fini (&clipper);
diff --git a/src/cairoint.h b/src/cairoint.h
index 28f3e9f..7121d09 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -1538,6 +1538,15 @@ _cairo_polygon_init_box_array (cairo_polygon_t *polygon,
 			       int num_boxes);
 
 cairo_private void
+_cairo_polygon_limit (cairo_polygon_t *polygon,
+		     const cairo_box_t *limits,
+		     int num_limits);
+
+cairo_private void
+_cairo_polygon_limit_to_clip (cairo_polygon_t *polygon,
+			      const cairo_clip_t *clip);
+
+cairo_private void
 _cairo_polygon_fini (cairo_polygon_t *polygon);
 
 cairo_private cairo_status_t
commit d576319e1346712a54802f372f742a24dbcdadd9
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Oct 12 16:28:30 2011 +0100

    recording-surface: Optimize away anything below an opaque fill
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-recording-surface.c b/src/cairo-recording-surface.c
index 8bcf5bc..5f87e6c 100644
--- a/src/cairo-recording-surface.c
+++ b/src/cairo-recording-surface.c
@@ -694,6 +694,15 @@ _cairo_recording_surface_paint (void			  *abstract_surface,
 	}
     }
 
+    if (clip == NULL && surface->optimize_clears &&
+	source->type == CAIRO_PATTERN_TYPE_SOLID &&
+	(op == CAIRO_OPERATOR_SOURCE ||
+	 (op == CAIRO_OPERATOR_OVER &&
+	  (surface->base.is_clear || _cairo_pattern_is_opaque_solid (source)))))
+    {
+	_cairo_recording_surface_reset (surface);
+    }
+
     status = _cairo_composite_rectangles_init_for_paint (&composite,
 							 &surface->base,
 							 op, source,


More information about the cairo-commit mailing list