[cairo-commit] 3 commits - boilerplate/cairo-boilerplate.c src/cairo-bentley-ottmann-rectangular.c src/cairo-surface-wrapper.c

Chris Wilson ickle at kemper.freedesktop.org
Sat Aug 13 03:09:18 PDT 2011


 boilerplate/cairo-boilerplate.c         |   18 +++++++++++++++---
 src/cairo-bentley-ottmann-rectangular.c |    2 +-
 src/cairo-surface-wrapper.c             |    3 ++-
 3 files changed, 18 insertions(+), 5 deletions(-)

New commits:
commit 7a17e4362e3b149ccb3590df690b91974416bfdf
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sat Aug 13 11:05:45 2011 +0100

    boilerplate: improve fidelity of surface extraction
    
    Create an image surface of equivalent content to the original.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index b89e6d8..229c4c7 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -274,6 +274,7 @@ _cairo_boilerplate_get_image_surface (cairo_surface_t *src,
     cairo_surface_t *surface, *image;
     cairo_t *cr;
     cairo_status_t status;
+    cairo_format_t format;
 
     if (cairo_surface_status (src))
 	return cairo_surface_reference (src);
@@ -282,7 +283,20 @@ _cairo_boilerplate_get_image_surface (cairo_surface_t *src,
 	return cairo_boilerplate_surface_create_in_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
 
     /* extract sub-surface */
-    surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
+    switch (cairo_surface_get_content (src)) {
+    case CAIRO_CONTENT_ALPHA:
+	format = CAIRO_FORMAT_A8;
+	break;
+    case CAIRO_CONTENT_COLOR:
+	format = CAIRO_FORMAT_RGB24;
+	break;
+    default:
+    case CAIRO_CONTENT_COLOR_ALPHA:
+	format = CAIRO_FORMAT_ARGB32;
+	break;
+    }
+    surface = cairo_image_surface_create (format, width, height);
+    assert (cairo_surface_get_content (surface) == cairo_surface_get_content (src));
     image = cairo_surface_reference (surface);
 
     /* open a logging channel (only interesting for recording surfaces) */
@@ -309,9 +323,7 @@ _cairo_boilerplate_get_image_surface (cairo_surface_t *src,
 
     cr = cairo_create (surface);
     cairo_surface_destroy (surface);
-
     cairo_set_source_surface (cr, src, 0, 0);
-    cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
     cairo_paint (cr);
 
     status = cairo_status (cr);
commit 9d5d46e8466f9417febfdefef6707bae9818b02d
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sat Aug 13 10:59:12 2011 +0100

    bo-rect: One step too far...
    
    Fixes a1-rasterisation-rectangles.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-bentley-ottmann-rectangular.c b/src/cairo-bentley-ottmann-rectangular.c
index c7e3277..5191178 100644
--- a/src/cairo-bentley-ottmann-rectangular.c
+++ b/src/cairo-bentley-ottmann-rectangular.c
@@ -163,7 +163,7 @@ rectangle_pop_stop (sweep_line_t *sweep)
 
     tail = elements[sweep->stop_size--];
     if (sweep->stop_size == 0) {
-	tail = NULL;
+	elements[PQ_FIRST_ENTRY] = NULL;
 	return;
     }
 
commit 4862aadb0fd1e5b7ea2710d56ff4984f3761611d
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sat Aug 13 10:48:21 2011 +0100

    surface-wrapper: Initialise clip to NULL
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-surface-wrapper.c b/src/cairo-surface-wrapper.c
index 0ce80a5..1682058 100644
--- a/src/cairo-surface-wrapper.c
+++ b/src/cairo-surface-wrapper.c
@@ -142,7 +142,7 @@ cairo_status_t
 _cairo_surface_wrapper_paint (cairo_surface_wrapper_t *wrapper,
 			      cairo_operator_t	 op,
 			      const cairo_pattern_t *source,
-			      const cairo_clip_t	    *clip)
+			      const cairo_clip_t    *clip)
 {
     cairo_status_t status;
     cairo_clip_t *dev_clip;
@@ -590,6 +590,7 @@ _cairo_surface_wrapper_init (cairo_surface_wrapper_t *wrapper,
     cairo_matrix_init_identity (&wrapper->transform);
     wrapper->has_extents = FALSE;
     wrapper->extents.x = wrapper->extents.y = 0;
+    wrapper->clip = NULL;
 
     wrapper->needs_transform = FALSE;
     if (target) {


More information about the cairo-commit mailing list