[cairo-commit] 3 commits - src/cairo-nquartz-surface.c test/caps-joins-alpha-nquartz-ref.png test/clip-nesting-nquartz-ref.png test/clip-nesting-nquartz-rgb24-ref.png test/clip-push-group-nquartz-ref.png test/clip-twice-nquartz-ref.png test/clip-twice-nquartz-rgb24-ref.png test/dash-caps-joins-nquartz-ref.png test/degenerate-path-nquartz-rgb24-ref.png test/fill-and-stroke-alpha-add-nquartz-ref.png test/fill-and-stroke-alpha-nquartz-ref.png test/fill-and-stroke-nquartz-ref.png test/fill-and-stroke-nquartz-rgb24-ref.png test/fill-degenerate-sort-order-nquartz-ref.png test/fill-degenerate-sort-order-nquartz-rgb24-ref.png test/fill-rule-nquartz-ref.png test/fill-rule-nquartz-rgb24-ref.png test/new-sub-path-nquartz-ref.png test/new-sub-path-nquartz-rgb24-ref.png test/operator-clear-nquartz-ref.png test/operator-clear-nquartz-rgb24-ref.png test/random-intersections-nquartz-ref.png test/random-intersections-nquartz-rgb24-ref.png test/rel-path-nquartz-ref.png test/rel-path-nquartz-rgb24-ref.png test/source-clip-scale-nquartz-ref.png test/trap-clip-nquartz-ref.png test/trap-clip-nquartz-rgb24-ref.png

Vladimir Vukicevic vladimir at kemper.freedesktop.org
Thu Jan 18 16:51:07 PST 2007


 src/cairo-nquartz-surface.c                           |   81 +++++++++++++++---
 test/caps-joins-alpha-nquartz-ref.png                 |binary
 test/clip-nesting-nquartz-ref.png                     |binary
 test/clip-nesting-nquartz-rgb24-ref.png               |binary
 test/clip-push-group-nquartz-ref.png                  |binary
 test/clip-twice-nquartz-ref.png                       |binary
 test/clip-twice-nquartz-rgb24-ref.png                 |binary
 test/dash-caps-joins-nquartz-ref.png                  |binary
 test/degenerate-path-nquartz-rgb24-ref.png            |binary
 test/fill-and-stroke-alpha-add-nquartz-ref.png        |binary
 test/fill-and-stroke-alpha-nquartz-ref.png            |binary
 test/fill-and-stroke-nquartz-ref.png                  |binary
 test/fill-and-stroke-nquartz-rgb24-ref.png            |binary
 test/fill-degenerate-sort-order-nquartz-ref.png       |binary
 test/fill-degenerate-sort-order-nquartz-rgb24-ref.png |binary
 test/fill-rule-nquartz-ref.png                        |binary
 test/fill-rule-nquartz-rgb24-ref.png                  |binary
 test/new-sub-path-nquartz-ref.png                     |binary
 test/new-sub-path-nquartz-rgb24-ref.png               |binary
 test/operator-clear-nquartz-ref.png                   |binary
 test/operator-clear-nquartz-rgb24-ref.png             |binary
 test/random-intersections-nquartz-ref.png             |binary
 test/random-intersections-nquartz-rgb24-ref.png       |binary
 test/rel-path-nquartz-ref.png                         |binary
 test/rel-path-nquartz-rgb24-ref.png                   |binary
 test/source-clip-scale-nquartz-ref.png                |binary
 test/trap-clip-nquartz-ref.png                        |binary
 test/trap-clip-nquartz-rgb24-ref.png                  |binary
 28 files changed, 68 insertions(+), 13 deletions(-)

New commits:
diff-tree d08502d939b44956591f2865a73264713427194b (from parents)
Merge: eefcfbf5a168569518a8dcf099b5f41b570f504b 28d6a228f030dbec05ab5b0ba680db272df67c49
Author: Vladimir Vukicevic <vladimir at pobox.com>
Date:   Thu Jan 18 16:50:41 2007 -0800

    Merge branch 'master' of git+ssh://git.cairographics.org/git/cairo

diff-tree eefcfbf5a168569518a8dcf099b5f41b570f504b (from 7b67c20a013ed45a10676cb129794ccfb66dc04c)
Author: Vladimir Vukicevic <vladimir at pobox.com>
Date:   Thu Jan 18 16:49:42 2007 -0800

    [nquartz] add test reference files for nquartz backend

diff --git a/test/caps-joins-alpha-nquartz-ref.png b/test/caps-joins-alpha-nquartz-ref.png
new file mode 100644
index 0000000..190c1e9
Binary files /dev/null and b/test/caps-joins-alpha-nquartz-ref.png differ
diff --git a/test/clip-nesting-nquartz-ref.png b/test/clip-nesting-nquartz-ref.png
new file mode 100644
index 0000000..5a3db7b
Binary files /dev/null and b/test/clip-nesting-nquartz-ref.png differ
diff --git a/test/clip-nesting-nquartz-rgb24-ref.png b/test/clip-nesting-nquartz-rgb24-ref.png
new file mode 100644
index 0000000..b55d116
Binary files /dev/null and b/test/clip-nesting-nquartz-rgb24-ref.png differ
diff --git a/test/clip-push-group-nquartz-ref.png b/test/clip-push-group-nquartz-ref.png
new file mode 100644
index 0000000..93c5268
Binary files /dev/null and b/test/clip-push-group-nquartz-ref.png differ
diff --git a/test/clip-twice-nquartz-ref.png b/test/clip-twice-nquartz-ref.png
new file mode 100644
index 0000000..f8231b3
Binary files /dev/null and b/test/clip-twice-nquartz-ref.png differ
diff --git a/test/clip-twice-nquartz-rgb24-ref.png b/test/clip-twice-nquartz-rgb24-ref.png
new file mode 100644
index 0000000..65cd80f
Binary files /dev/null and b/test/clip-twice-nquartz-rgb24-ref.png differ
diff --git a/test/dash-caps-joins-nquartz-ref.png b/test/dash-caps-joins-nquartz-ref.png
new file mode 100644
index 0000000..5e4aa76
Binary files /dev/null and b/test/dash-caps-joins-nquartz-ref.png differ
diff --git a/test/degenerate-path-nquartz-rgb24-ref.png b/test/degenerate-path-nquartz-rgb24-ref.png
new file mode 100644
index 0000000..6be052e
Binary files /dev/null and b/test/degenerate-path-nquartz-rgb24-ref.png differ
diff --git a/test/fill-and-stroke-alpha-add-nquartz-ref.png b/test/fill-and-stroke-alpha-add-nquartz-ref.png
new file mode 100644
index 0000000..d648eec
Binary files /dev/null and b/test/fill-and-stroke-alpha-add-nquartz-ref.png differ
diff --git a/test/fill-and-stroke-alpha-nquartz-ref.png b/test/fill-and-stroke-alpha-nquartz-ref.png
new file mode 100644
index 0000000..0121479
Binary files /dev/null and b/test/fill-and-stroke-alpha-nquartz-ref.png differ
diff --git a/test/fill-and-stroke-nquartz-ref.png b/test/fill-and-stroke-nquartz-ref.png
new file mode 100644
index 0000000..4c48d24
Binary files /dev/null and b/test/fill-and-stroke-nquartz-ref.png differ
diff --git a/test/fill-and-stroke-nquartz-rgb24-ref.png b/test/fill-and-stroke-nquartz-rgb24-ref.png
new file mode 100644
index 0000000..5972d56
Binary files /dev/null and b/test/fill-and-stroke-nquartz-rgb24-ref.png differ
diff --git a/test/fill-degenerate-sort-order-nquartz-ref.png b/test/fill-degenerate-sort-order-nquartz-ref.png
new file mode 100644
index 0000000..0ea4a67
Binary files /dev/null and b/test/fill-degenerate-sort-order-nquartz-ref.png differ
diff --git a/test/fill-degenerate-sort-order-nquartz-rgb24-ref.png b/test/fill-degenerate-sort-order-nquartz-rgb24-ref.png
new file mode 100644
index 0000000..59e1cb6
Binary files /dev/null and b/test/fill-degenerate-sort-order-nquartz-rgb24-ref.png differ
diff --git a/test/fill-rule-nquartz-ref.png b/test/fill-rule-nquartz-ref.png
new file mode 100644
index 0000000..f7e616c
Binary files /dev/null and b/test/fill-rule-nquartz-ref.png differ
diff --git a/test/fill-rule-nquartz-rgb24-ref.png b/test/fill-rule-nquartz-rgb24-ref.png
new file mode 100644
index 0000000..8b180c5
Binary files /dev/null and b/test/fill-rule-nquartz-rgb24-ref.png differ
diff --git a/test/new-sub-path-nquartz-ref.png b/test/new-sub-path-nquartz-ref.png
new file mode 100644
index 0000000..e9c40b9
Binary files /dev/null and b/test/new-sub-path-nquartz-ref.png differ
diff --git a/test/new-sub-path-nquartz-rgb24-ref.png b/test/new-sub-path-nquartz-rgb24-ref.png
new file mode 100644
index 0000000..efc907e
Binary files /dev/null and b/test/new-sub-path-nquartz-rgb24-ref.png differ
diff --git a/test/operator-clear-nquartz-ref.png b/test/operator-clear-nquartz-ref.png
new file mode 100644
index 0000000..d79d4c3
Binary files /dev/null and b/test/operator-clear-nquartz-ref.png differ
diff --git a/test/operator-clear-nquartz-rgb24-ref.png b/test/operator-clear-nquartz-rgb24-ref.png
new file mode 100644
index 0000000..d47ce75
Binary files /dev/null and b/test/operator-clear-nquartz-rgb24-ref.png differ
diff --git a/test/random-intersections-nquartz-ref.png b/test/random-intersections-nquartz-ref.png
new file mode 100644
index 0000000..a687088
Binary files /dev/null and b/test/random-intersections-nquartz-ref.png differ
diff --git a/test/random-intersections-nquartz-rgb24-ref.png b/test/random-intersections-nquartz-rgb24-ref.png
new file mode 100644
index 0000000..77f73cd
Binary files /dev/null and b/test/random-intersections-nquartz-rgb24-ref.png differ
diff --git a/test/rel-path-nquartz-ref.png b/test/rel-path-nquartz-ref.png
new file mode 100644
index 0000000..5878ce4
Binary files /dev/null and b/test/rel-path-nquartz-ref.png differ
diff --git a/test/rel-path-nquartz-rgb24-ref.png b/test/rel-path-nquartz-rgb24-ref.png
new file mode 100644
index 0000000..0e33b66
Binary files /dev/null and b/test/rel-path-nquartz-rgb24-ref.png differ
diff --git a/test/source-clip-scale-nquartz-ref.png b/test/source-clip-scale-nquartz-ref.png
new file mode 100644
index 0000000..f21ae4b
Binary files /dev/null and b/test/source-clip-scale-nquartz-ref.png differ
diff --git a/test/trap-clip-nquartz-ref.png b/test/trap-clip-nquartz-ref.png
new file mode 100644
index 0000000..28f5977
Binary files /dev/null and b/test/trap-clip-nquartz-ref.png differ
diff --git a/test/trap-clip-nquartz-rgb24-ref.png b/test/trap-clip-nquartz-rgb24-ref.png
new file mode 100644
index 0000000..24da4b9
Binary files /dev/null and b/test/trap-clip-nquartz-rgb24-ref.png differ
diff-tree 7b67c20a013ed45a10676cb129794ccfb66dc04c (from d9df44d8071d038060e0cc987871c185f7733a3d)
Author: Vladimir Vukicevic <vladimir at pobox.com>
Date:   Thu Jan 18 16:49:14 2007 -0800

    [nquartz] use pattern snapshots, and correctly setup/teardown source
    
    Use a snapshot for the pattern, to avoid the pattern being freed undreneath
    us before we actually render (as when rendering to a CG PDF context).  Also
    correctly return UNSUPPORTED from setup source, avoiding brokenness when
    the source isn't torn down correctly.

diff --git a/src/cairo-nquartz-surface.c b/src/cairo-nquartz-surface.c
index 15b3d61..dd05c38 100644
--- a/src/cairo-nquartz-surface.c
+++ b/src/cairo-nquartz-surface.c
@@ -548,6 +548,29 @@ SurfacePatternDrawFunc (void *info, CGCo
     cairo_surface_destroy ((cairo_surface_t*) quartz_surf);
 }
 
+/* Borrowed from cairo-meta-surface */
+static cairo_status_t
+_init_pattern_with_snapshot (cairo_pattern_t *pattern,
+			     const cairo_pattern_t *other)
+{
+    _cairo_pattern_init_copy (pattern, other);
+
+    if (pattern->type == CAIRO_PATTERN_TYPE_SURFACE) {
+	cairo_surface_pattern_t *surface_pattern =
+	    (cairo_surface_pattern_t *) pattern;
+	cairo_surface_t *surface = surface_pattern->surface;
+
+	surface_pattern->surface = _cairo_surface_snapshot (surface);
+
+	cairo_surface_destroy (surface);
+
+	if (surface_pattern->surface->status)
+	    return surface_pattern->surface->status;
+    }
+
+    return CAIRO_STATUS_SUCCESS;
+}
+
 static CGPatternRef
 _cairo_nquartz_cairo_repeating_surface_pattern_to_quartz (cairo_nquartz_surface_t *dest,
 							  cairo_pattern_t *abspat)
@@ -564,6 +587,9 @@ _cairo_nquartz_cairo_repeating_surface_p
     CGPatternRef cgpat;
     float rw, rh;
 
+    cairo_pattern_union_t *snap_pattern = NULL;
+    cairo_pattern_t *target_pattern = abspat;
+
     /* SURFACE is the only type we'll handle here */
     if (abspat->type != CAIRO_PATTERN_TYPE_SURFACE)
 	return NULL;
@@ -628,8 +654,18 @@ _cairo_nquartz_cairo_repeating_surface_p
     rh = extents.height;
 #endif
 
-    cairo_pattern_reference (abspat);
-    cgpat = CGPatternCreate (abspat,
+    /* XXX fixme: only do snapshots if the context is for printing, or get rid of the
+       other block if it doesn't fafect performance */
+    if (1 /* context is for printing */) {
+	snap_pattern = (cairo_pattern_union_t*) malloc(sizeof(cairo_pattern_union_t));
+	target_pattern = (cairo_pattern_t*) snap_pattern;
+	_init_pattern_with_snapshot (snap_pattern, abspat);
+    } else {
+	cairo_pattern_reference (abspat);
+	target_pattern = abspat;
+    }
+
+    cgpat = CGPatternCreate (target_pattern,
 			     pbounds,
 			     ptransform,
 			     rw, rh,
@@ -672,7 +708,7 @@ _cairo_nquartz_setup_source (cairo_nquar
     {
 	CGShadingRef shading = _cairo_nquartz_cairo_gradient_pattern_to_quartz (source);
 	if (!shading)
-	    return CAIRO_INT_STATUS_UNSUPPORTED;
+	    return DO_UNSUPPORTED;
 
 	surface->sourceShading = shading;
 
@@ -680,7 +716,7 @@ _cairo_nquartz_setup_source (cairo_nquar
     } else if (source->type == CAIRO_PATTERN_TYPE_SURFACE) {
 	CGPatternRef pattern = _cairo_nquartz_cairo_repeating_surface_pattern_to_quartz (surface, source);
 	if (!pattern)
-	    return CAIRO_INT_STATUS_UNSUPPORTED;
+	    return DO_UNSUPPORTED;
 
 	float patternAlpha = 1.0f;
 
@@ -692,6 +728,8 @@ _cairo_nquartz_setup_source (cairo_nquar
 	CGColorSpaceRef patternSpace = CGColorSpaceCreatePattern(NULL);
 	CGContextSetFillColorSpace (surface->cgContext, patternSpace);
 	CGContextSetFillPattern (surface->cgContext, pattern, &patternAlpha);
+	CGContextSetStrokeColorSpace (surface->cgContext, patternSpace);
+	CGContextSetStrokePattern (surface->cgContext, pattern, &patternAlpha);
 	CGColorSpaceRelease (patternSpace);
 
 	/* Quartz likes to munge the pattern phase (as yet unexplained
@@ -1247,7 +1285,9 @@ _cairo_nquartz_surface_stroke (void *abs
 
     CGContextSaveGState (surface->cgContext);
 
-    CGContextSetShouldAntialias (surface->cgContext, (antialias != CAIRO_ANTIALIAS_NONE));
+    // Turning antialiasing off causes misrendering with
+    // single-pixel lines (e.g. 20,10.5 -> 21,10.5 end up being rendered as 2 pixels)
+    //CGContextSetShouldAntialias (surface->cgContext, (antialias != CAIRO_ANTIALIAS_NONE));
     CGContextSetLineWidth (surface->cgContext, style->line_width);
     CGContextSetLineCap (surface->cgContext, _cairo_nquartz_cairo_line_cap_to_quartz (style->line_cap));
     CGContextSetLineJoin (surface->cgContext, _cairo_nquartz_cairo_line_join_to_quartz (style->line_join));
@@ -1294,6 +1334,8 @@ _cairo_nquartz_surface_stroke (void *abs
 	rv = CAIRO_INT_STATUS_UNSUPPORTED;
     }
 
+    _cairo_nquartz_teardown_source (surface, source);
+
     CGContextRestoreGState (surface->cgContext);
 
     ND((stderr, "-- stroke\n"));
@@ -1363,8 +1405,16 @@ _cairo_nquartz_surface_show_glyphs (void
     CGContextSetFontSize (surface->cgContext, 1.0);
 
     // XXXtodo/perf: stack storage for glyphs/sizes
-    CGGlyph *cg_glyphs = (CGGlyph*) malloc(sizeof(CGGlyph) * num_glyphs);
-    CGSize *cg_advances = (CGSize*) malloc(sizeof(CGSize) * num_glyphs);
+#define STATIC_BUF_SIZE 64
+    CGGlyph glyphs_static[STATIC_BUF_SIZE];
+    CGSize cg_advances_static[STATIC_BUF_SIZE];
+    CGGlyph *cg_glyphs = &glyphs_static[0];
+    CGSize *cg_advances = &cg_advances_static[0];
+
+    if (num_glyphs > STATIC_BUF_SIZE) {
+	cg_glyphs = (CGGlyph*) malloc(sizeof(CGGlyph) * num_glyphs);
+	cg_advances = (CGSize*) malloc(sizeof(CGSize) * num_glyphs);
+    }
 
     double xprev = glyphs[0].x;
     double yprev = glyphs[0].y;
@@ -1392,8 +1442,10 @@ _cairo_nquartz_surface_show_glyphs (void
 				     cg_advances,
 				     num_glyphs);
 
-    free (cg_glyphs);
-    free (cg_advances);
+    if (cg_glyphs != &glyphs_static[0]) {
+	free (cg_glyphs);
+	free (cg_advances);
+    }
 
     if (action == DO_SHADING)
 	CGContextDrawShading (surface->cgContext, surface->sourceShading);
@@ -1422,10 +1474,13 @@ _cairo_nquartz_surface_mask (void *abstr
 
 	CGContextSetAlpha (surface->cgContext, solid_mask->color.alpha);
     } else {
-	/* So, CGContextClipToMask is not present in 10.3.9, so we're doomed; we could
-	 * do fallback, if we implemented _composite, but for now let's just not support
-	 * this.  (But pretend we did.)
+	/* So, CGContextClipToMask is not present in 10.3.9, so we're
+	 * doomed; if we have imageData, we can do fallback, otherwise
+	 * just pretend success.
 	 */
+	if (surface->imageData)
+	    return CAIRO_INT_STATUS_UNSUPPORTED;
+
 	return CAIRO_STATUS_SUCCESS;
     }
 
@@ -1646,7 +1701,7 @@ cairo_nquartz_surface_create (cairo_form
 	if (width % 4 == 0)
 	    stride = width;
 	else
-	    stride = (width & 3) + 1;
+	    stride = (width & ~3) + 4;
 	bitinfo = kCGImageAlphaNone;
 	bitsPerComponent = 8;
     } else if (format == CAIRO_FORMAT_A1) {


More information about the cairo-commit mailing list