[cairo-commit] 3 commits - src/cairoint.h src/cairo-operator.c src/cairo-pattern.c src/cairo-pdf-surface.c src/cairo-ps-surface.c src/cairo-surface.c src/Makefile.am test/.gitignore

Carl Worth cworth at kemper.freedesktop.org
Fri Apr 14 17:29:21 PDT 2006


 src/Makefile.am         |    1 
 src/cairo-operator.c    |  119 ++++++++++++++++++++++++++++++++++++++++
 src/cairo-pattern.c     |   44 ++++++++++++++
 src/cairo-pdf-surface.c |    6 +-
 src/cairo-ps-surface.c  |  142 ++----------------------------------------------
 src/cairo-surface.c     |   28 +++++++++
 src/cairoint.h          |   15 ++++-
 test/.gitignore         |    1 
 8 files changed, 216 insertions(+), 140 deletions(-)

New commits:
diff-tree e890bfd2bf04a973ead9f5d53d06728165faa28d (from b7309d065e49ae73ff8d90feca35f6b8f35922d2)
Author: Carl Worth <cworth at cworth.org>
Date:   Fri Apr 14 17:26:23 2006 -0700

    Ignore dash-zero-length

diff --git a/test/.gitignore b/test/.gitignore
index 8a1a8ac..8060e7b 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -19,6 +19,7 @@ create-from-png
 create-from-png-stream
 dash-caps-joins
 dash-offset-negative
+dash-zero-length
 extend-reflect
 fill-and-stroke
 fill-rule
diff-tree b7309d065e49ae73ff8d90feca35f6b8f35922d2 (from a7f4f1b350e158eca394da63eed0e14a97480a5a)
Author: Carl Worth <cworth at cworth.org>
Date:   Fri Apr 14 17:25:54 2006 -0700

    Farm out the surface and pattern analysis functions away from cairo-ps-surface.c.
    
    We're setting things up here for better sharing as PDF surface (and
    others) now want to do some of the same analysis.

diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index 8aa2969..3f0b5e4 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -1050,7 +1050,6 @@ _cairo_pattern_acquire_surface_for_solid
     return CAIRO_STATUS_SUCCESS;
 }
 
-
 /**
  * _cairo_pattern_is_opaque_solid
  *
@@ -1063,7 +1062,7 @@ _cairo_pattern_acquire_surface_for_solid
  * Return value: %TRUE if the pattern is an opaque, solid color.
  **/
 cairo_bool_t 
-_cairo_pattern_is_opaque_solid (cairo_pattern_t *pattern)
+_cairo_pattern_is_opaque_solid (const cairo_pattern_t *pattern)
 {
     cairo_solid_pattern_t *solid;
 
@@ -1075,6 +1074,47 @@ _cairo_pattern_is_opaque_solid (cairo_pa
     return CAIRO_ALPHA_IS_OPAQUE (solid->color.alpha);
 }
 
+static cairo_bool_t
+_gradient_is_opaque (const cairo_gradient_pattern_t *gradient)
+{
+    int i;
+    
+    for (i = 0; i < gradient->n_stops; i++)
+	if (! CAIRO_ALPHA_IS_OPAQUE (gradient->stops[i].color.alpha))
+	    return FALSE;
+
+    return TRUE;
+}
+
+/**
+ * _cairo_pattern_is_opaque
+ *
+ * Convenience function to determine whether a pattern is an opaque
+ * pattern (of any type). The same caveats that apply to
+ * _cairo_pattern_is_opaque_solid apply here as well.
+ *
+ * Return value: %TRUE if the pattern is a opaque.
+ **/
+cairo_bool_t
+_cairo_pattern_is_opaque (const cairo_pattern_t *abstract_pattern)
+{
+    const cairo_pattern_union_t *pattern;
+
+    pattern = (cairo_pattern_union_t *) abstract_pattern;
+    switch (pattern->base.type) {
+    case CAIRO_PATTERN_TYPE_SOLID:
+	return _cairo_pattern_is_opaque_solid (abstract_pattern);
+    case CAIRO_PATTERN_TYPE_SURFACE:
+	return _cairo_surface_is_opaque (pattern->surface.surface);
+    case CAIRO_PATTERN_TYPE_LINEAR:
+    case CAIRO_PATTERN_TYPE_RADIAL:
+	return _gradient_is_opaque (&pattern->gradient.base);
+    }	
+
+    ASSERT_NOT_REACHED;
+    return FALSE;
+}
+
 static cairo_int_status_t
 _cairo_pattern_acquire_surface_for_surface (cairo_surface_pattern_t   *pattern,
 					    cairo_surface_t	       *dst,
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 8c867ec..9f4e590 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -2048,7 +2048,11 @@ _cairo_pdf_surface_paint (void			*abstra
     if (surface->paginated_mode == CAIRO_PAGINATED_MODE_ANALYZE)
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
-    ASSERT_NOT_REACHED;
+    /* One would think that since we analyzed this away as unsupported
+     * that it would never be called after analyzing. But in fact,
+     * paint is called to paint the actual fallback surface. So we
+     * must not ASSERT_NOT_REACHED as we do for the other drawing
+     * operations. */
 
     return CAIRO_INT_STATUS_UNSUPPORTED;
 }
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 1bf2863..19a835b 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -902,73 +902,6 @@ color_is_gray (cairo_color_t *color)
 }
 
 static cairo_bool_t
-color_is_opaque (const cairo_color_t *color)
-{
-    return color->alpha >= 0.999;
-}
-
-static cairo_bool_t
-format_is_opaque (cairo_format_t format)
-{
-    switch (format) {
-    case CAIRO_FORMAT_ARGB32:
-	return FALSE;
-    case CAIRO_FORMAT_RGB24:
-	return TRUE;
-    case CAIRO_FORMAT_A8:
-	return FALSE;
-    case CAIRO_FORMAT_A1:
-	return TRUE;
-    }
-    return FALSE;
-}
-
-static cairo_bool_t
-surface_is_opaque (const cairo_surface_t *surface)
-{ 
-    if (_cairo_surface_is_image (surface)) {
-	const cairo_image_surface_t	*image_surface = (cairo_image_surface_t *) surface;
-
-	return format_is_opaque (image_surface->format);
-    }
-    return TRUE;
-}
-
-static cairo_bool_t
-gradient_is_opaque (const cairo_gradient_pattern_t *gradient)
-{
-    return FALSE;    /* XXX no gradient support */
-#if 0
-    int i;
-    
-    for (i = 0; i < gradient->n_stops; i++)
-	if (!color_is_opaque (&gradient->stops[i].color))
-	    return FALSE;
-    return TRUE;
-#endif
-}
-
-static cairo_bool_t
-pattern_is_opaque (const cairo_pattern_t *abstract_pattern)
-{
-    const cairo_pattern_union_t *pattern;
-
-    pattern = (cairo_pattern_union_t *) abstract_pattern;
-    switch (pattern->base.type) {
-    case CAIRO_PATTERN_TYPE_SOLID:
-	return color_is_opaque (&pattern->solid.color);
-    case CAIRO_PATTERN_TYPE_SURFACE:
-	return surface_is_opaque (pattern->surface.surface);
-    case CAIRO_PATTERN_TYPE_LINEAR:
-    case CAIRO_PATTERN_TYPE_RADIAL:
-	return gradient_is_opaque (&pattern->gradient.base);
-    }	
-
-    ASSERT_NOT_REACHED;
-    return FALSE;
-}
-
-static cairo_bool_t
 surface_pattern_supported (const cairo_surface_pattern_t *pattern)
 {
     if (pattern->surface->backend->acquire_source_image != NULL)
@@ -1003,7 +936,7 @@ operation_supported (cairo_ps_surface_t 
     if (_cairo_operator_always_translucent (op))
 	return FALSE;
 
-    return pattern_is_opaque (pattern);
+    return _cairo_pattern_is_opaque (pattern);
 }
 
 static cairo_int_status_t
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index d0810aa..5af49da 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -1693,3 +1693,31 @@ _cairo_surface_composite_shape_fixup_unb
     return _cairo_surface_composite_fixup_unbounded_internal (dst, src_rectangle, mask_rectangle,
 							      dst_x, dst_y, width, height);
 }
+
+static cairo_bool_t
+_format_is_opaque (cairo_format_t format)
+{
+    switch (format) {
+    case CAIRO_FORMAT_ARGB32:
+	return FALSE;
+    case CAIRO_FORMAT_RGB24:
+	return TRUE;
+    case CAIRO_FORMAT_A8:
+	return FALSE;
+    case CAIRO_FORMAT_A1:
+	return TRUE;
+    }
+    return FALSE;
+}
+
+cairo_bool_t
+_cairo_surface_is_opaque (const cairo_surface_t *surface)
+{ 
+    if (_cairo_surface_is_image (surface)) {
+	const cairo_image_surface_t *image_surface = (cairo_image_surface_t *) surface;
+
+	return _format_is_opaque (image_surface->format);
+    }
+
+    return TRUE;
+}
diff --git a/src/cairoint.h b/src/cairoint.h
index 03fc489..a3d4bbe 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -1826,6 +1826,9 @@ _cairo_surface_composite_shape_fixup_unb
 						unsigned int		    width,
 						unsigned int		    height);
 
+cairo_private cairo_bool_t
+_cairo_surface_is_opaque (const cairo_surface_t *surface);
+
 /* cairo_image_surface.c */
 
 #define CAIRO_FORMAT_VALID(format) ((format) >= CAIRO_FORMAT_ARGB32 && \
@@ -2075,7 +2078,10 @@ _cairo_pattern_transform (cairo_pattern_
 			  const cairo_matrix_t *ctm_inverse);
 
 cairo_private cairo_bool_t 
-_cairo_pattern_is_opaque_solid (cairo_pattern_t *pattern);
+_cairo_pattern_is_opaque_solid (const cairo_pattern_t *pattern);
+
+cairo_bool_t
+_cairo_pattern_is_opaque (const cairo_pattern_t *abstract_pattern);
 
 cairo_private cairo_int_status_t
 _cairo_pattern_acquire_surface (cairo_pattern_t		   *pattern,
diff-tree a7f4f1b350e158eca394da63eed0e14a97480a5a (from c7fd35fac2bc7c93e85ccbe50b20529ae4d9479d)
Author: Carl Worth <cworth at cworth.org>
Date:   Fri Apr 14 17:03:39 2006 -0700

    Move analysis of operators from cairo-ps-surface.c to cairo-operator.c

diff --git a/src/Makefile.am b/src/Makefile.am
index 43ffcd7..4ccf327 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -153,6 +153,7 @@ libcairo_la_SOURCES =				\
 	cairo-image-surface.c			\
 	cairo-lzw.c				\
 	cairo-matrix.c				\
+	cairo-operator.c			\
 	cairo-path.c				\
 	cairo-path-bounds.c			\
 	cairo-path-data.c			\
diff --git a/src/cairo-operator.c b/src/cairo-operator.c
new file mode 100644
index 0000000..99c3aaa
--- /dev/null
+++ b/src/cairo-operator.c
@@ -0,0 +1,119 @@
+/* cairo - a vector graphics library with display and print output
+ *
+ * Copyright © 2006 Keith Packard
+ * Copyright © 2006 Red Hat, Inc
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it either under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation
+ * (the "LGPL") or, at your option, under the terms of the Mozilla
+ * Public License Version 1.1 (the "MPL"). If you do not alter this
+ * notice, a recipient may use your version of this file under either
+ * the MPL or the LGPL.
+ *
+ * You should have received a copy of the LGPL along with this library
+ * in the file COPYING-LGPL-2.1; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the MPL along with this library
+ * in the file COPYING-MPL-1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
+ * OF ANY KIND, either express or implied. See the LGPL or the MPL for
+ * the specific language governing rights and limitations.
+ *
+ * The Original Code is the cairo graphics library.
+ *
+ * The Initial Developer of the Original Code is University of Southern
+ * California.
+ *
+ * Contributor(s):
+ *	Carl D. Worth <cworth at cworth.org>
+ *	Keith Packard <keithp at keithp.com>
+ */
+
+#include "cairoint.h"
+
+/* The analysis here assumes destination alpha semantics (that is
+ * CAIRO_CONTENT_COLOR_ALPHA). More things can be considered opaque
+ * otherwise (CAIRO_CONTENT_COLOR) so we'll probably want to add a
+ * cairo_content_t parameter to this function
+ *
+ * We also need a definition of what "opaque" means. Is it, "does not
+ * requiring 'knowing' the original contents of destination, nor does
+ * it set the destination alpha to anything but 1.0" ?
+ */
+cairo_bool_t
+_cairo_operator_always_opaque (cairo_operator_t op)
+{
+    switch (op) {
+    case CAIRO_OPERATOR_CLEAR:
+	return FALSE;
+
+    case CAIRO_OPERATOR_SOURCE:
+	return FALSE;
+	
+    case CAIRO_OPERATOR_OVER:
+    case CAIRO_OPERATOR_IN:
+    case CAIRO_OPERATOR_OUT:
+    case CAIRO_OPERATOR_ATOP:
+	return FALSE;
+
+    case CAIRO_OPERATOR_DEST:
+	return TRUE;
+	
+    case CAIRO_OPERATOR_DEST_OVER:
+    case CAIRO_OPERATOR_DEST_IN:
+    case CAIRO_OPERATOR_DEST_OUT:
+    case CAIRO_OPERATOR_DEST_ATOP:
+	return FALSE;
+
+    case CAIRO_OPERATOR_XOR:
+    case CAIRO_OPERATOR_ADD:
+    case CAIRO_OPERATOR_SATURATE:
+	return FALSE;
+    }
+    return FALSE;
+}
+
+/* As above, we'll probably want to add a cairo_content_t parameter to
+ * this function
+ *
+ * We also need a definition of what "translucent" means.
+ */
+cairo_bool_t
+_cairo_operator_always_translucent (cairo_operator_t op)
+{
+    switch (op) {
+    case CAIRO_OPERATOR_CLEAR:
+	return TRUE;
+
+    case CAIRO_OPERATOR_SOURCE:
+	return FALSE;
+	
+    case CAIRO_OPERATOR_OVER:
+    case CAIRO_OPERATOR_IN:
+    case CAIRO_OPERATOR_OUT:
+    case CAIRO_OPERATOR_ATOP:
+	return FALSE;
+
+    case CAIRO_OPERATOR_DEST:
+	return FALSE;
+	
+    case CAIRO_OPERATOR_DEST_OVER:
+    case CAIRO_OPERATOR_DEST_IN:
+    case CAIRO_OPERATOR_DEST_OUT:
+    case CAIRO_OPERATOR_DEST_ATOP:
+	return FALSE;
+
+    case CAIRO_OPERATOR_XOR:
+    case CAIRO_OPERATOR_ADD:
+    case CAIRO_OPERATOR_SATURATE:
+	return TRUE;
+    }
+    return TRUE;
+}
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 9319f83..1bf2863 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -969,76 +969,11 @@ pattern_is_opaque (const cairo_pattern_t
 }
 
 static cairo_bool_t
-operator_always_opaque (cairo_operator_t op)
-{
-    switch (op) {
-    case CAIRO_OPERATOR_CLEAR:
-	return FALSE;
-
-    case CAIRO_OPERATOR_SOURCE:
-	return FALSE;
-	
-    case CAIRO_OPERATOR_OVER:
-    case CAIRO_OPERATOR_IN:
-    case CAIRO_OPERATOR_OUT:
-    case CAIRO_OPERATOR_ATOP:
-	return FALSE;
-
-    case CAIRO_OPERATOR_DEST:
-	return TRUE;
-	
-    case CAIRO_OPERATOR_DEST_OVER:
-    case CAIRO_OPERATOR_DEST_IN:
-    case CAIRO_OPERATOR_DEST_OUT:
-    case CAIRO_OPERATOR_DEST_ATOP:
-	return FALSE;
-
-    case CAIRO_OPERATOR_XOR:
-    case CAIRO_OPERATOR_ADD:
-    case CAIRO_OPERATOR_SATURATE:
-	return FALSE;
-    }
-    return FALSE;
-}
-
-static cairo_bool_t
-operator_always_translucent (cairo_operator_t op)
-{
-    switch (op) {
-    case CAIRO_OPERATOR_CLEAR:
-	return TRUE;
-
-    case CAIRO_OPERATOR_SOURCE:
-	return FALSE;
-	
-    case CAIRO_OPERATOR_OVER:
-    case CAIRO_OPERATOR_IN:
-    case CAIRO_OPERATOR_OUT:
-    case CAIRO_OPERATOR_ATOP:
-	return FALSE;
-
-    case CAIRO_OPERATOR_DEST:
-	return FALSE;
-	
-    case CAIRO_OPERATOR_DEST_OVER:
-    case CAIRO_OPERATOR_DEST_IN:
-    case CAIRO_OPERATOR_DEST_OUT:
-    case CAIRO_OPERATOR_DEST_ATOP:
-	return FALSE;
-
-    case CAIRO_OPERATOR_XOR:
-    case CAIRO_OPERATOR_ADD:
-    case CAIRO_OPERATOR_SATURATE:
-	return TRUE;
-    }
-    return TRUE;
-}
-
-static cairo_bool_t
 surface_pattern_supported (const cairo_surface_pattern_t *pattern)
 {
     if (pattern->surface->backend->acquire_source_image != NULL)
 	return TRUE;
+
     return FALSE;
 }
 
@@ -1047,6 +982,7 @@ pattern_supported (const cairo_pattern_t
 {
     if (pattern->type == CAIRO_PATTERN_TYPE_SOLID)
 	return TRUE;
+
     if (pattern->type == CAIRO_PATTERN_TYPE_SURFACE)
 	return surface_pattern_supported ((const cairo_surface_pattern_t *) pattern);
 	
@@ -1061,9 +997,10 @@ operation_supported (cairo_ps_surface_t 
     if (! pattern_supported (pattern))
 	return FALSE;
 
-    if (operator_always_opaque (op))
+    if (_cairo_operator_always_opaque (op))
 	return TRUE;
-    if (operator_always_translucent (op))
+
+    if (_cairo_operator_always_translucent (op))
 	return FALSE;
 
     return pattern_is_opaque (pattern);
diff --git a/src/cairoint.h b/src/cairoint.h
index 51829c9..03fc489 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -1390,6 +1390,13 @@ _cairo_font_options_init_copy (cairo_fon
 cairo_private cairo_status_t
 _cairo_hull_compute (cairo_pen_vertex_t *vertices, int *num_vertices);
 
+/* cairo_operator.c */
+cairo_private cairo_bool_t
+_cairo_operator_always_opaque (cairo_operator_t op);
+
+cairo_private cairo_bool_t
+_cairo_operator_always_translucent (cairo_operator_t op);
+
 /* cairo_path.c */
 cairo_private void
 _cairo_path_fixed_init (cairo_path_fixed_t *path);


More information about the cairo-commit mailing list