[cairo-commit] Branch 'ps-surface' - 5 commits - src/cairo-paginated-surface.c src/cairo-pdf-surface.c src/cairo-ps-surface.c

Carl Worth cworth at kemper.freedesktop.org
Fri Mar 24 12:10:53 PST 2006


 src/cairo-paginated-surface.c |   11 -------
 src/cairo-pdf-surface.c       |   19 ++++++++++++
 src/cairo-ps-surface.c        |   63 +++++++++++++++++++++++++-----------------
 3 files changed, 57 insertions(+), 36 deletions(-)

New commits:
diff-tree edb83e306bda8a78a8a72006f257922cda7adc69 (from 29dad9867aa5f00f4f38da5da7df6aded794682c)
Author: Carl Worth <cworth at cworth.org>
Date:   Fri Mar 24 12:07:21 2006 -0800

    cairo-ps-surface: Simplify operation analysis.
    
    Introduce a new pattern_operation_analyze function which allows a much
    simpler idiom to be used by all of the drawing operations. This also
    provides new assertions that when we are not analyzing we are never
    called to perform an operation that we would analyze as
    unsupported.

diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index f90a9c8..305240a 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -644,7 +644,7 @@ pattern_supported (const cairo_pattern_t
 
 static cairo_bool_t
 pattern_operation_supported (cairo_operator_t op,
-				  const cairo_pattern_t *pattern)
+			     const cairo_pattern_t *pattern)
 {
     if (! pattern_supported (pattern))
 	return FALSE;
@@ -655,6 +655,16 @@ pattern_operation_supported (cairo_opera
     return pattern_is_opaque (pattern);
 }
 
+static cairo_int_status_t
+pattern_operation_analyze (cairo_operator_t op,
+			   const cairo_pattern_t *pattern)
+{
+    if (pattern_operation_supported (op, pattern))
+	return CAIRO_STATUS_SUCCESS;
+    else
+	return CAIRO_INT_STATUS_UNSUPPORTED;
+}
+
 /* PS Output - this section handles output of the parts of the meta
  * surface we can render natively in PS. */
 
@@ -1132,11 +1142,18 @@ _cairo_ps_surface_paint (void			*abstrac
     cairo_output_stream_t *stream = surface->stream;
     cairo_ps_surface_path_info_t info;
 
-    if (surface->paginated_mode == CAIRO_PAGINATED_MODE_ANALYZE) {
-	if (!pattern_operation_supported (op, source))
-	    return CAIRO_INT_STATUS_UNSUPPORTED;
-	return CAIRO_STATUS_SUCCESS;
-    }
+    if (surface->paginated_mode == CAIRO_PAGINATED_MODE_ANALYZE)
+	return pattern_operation_analyze (op, source);
+
+    /* XXX: It would be nice to be able to assert this condition
+     * here. But, we actually allow one 'cheat' that is used when
+     * painting the final image-based fallbacks. The final fallbacks
+     * do have alpha which we support by blending with white. This is
+     * possible only because there is nothing between the fallback
+     * images and the paper, nor is anything painted above. */
+    /*
+    assert (pattern_operation_supported (op, source));
+    */
     
     if (surface->need_start_page)
 	_cairo_ps_surface_start_page (surface);
@@ -1206,12 +1223,10 @@ _cairo_ps_surface_stroke (void			*abstra
     cairo_int_status_t status;
     cairo_ps_surface_path_info_t info;
 
-    if (surface->paginated_mode == CAIRO_PAGINATED_MODE_ANALYZE) {
-	if (!pattern_operation_supported (op, source))
-	    return CAIRO_INT_STATUS_UNSUPPORTED;
-    
-	return CAIRO_STATUS_SUCCESS;
-    }
+    if (surface->paginated_mode == CAIRO_PAGINATED_MODE_ANALYZE)
+	return pattern_operation_analyze (op, source);
+
+    assert (pattern_operation_supported (op, source));
     
     if (surface->need_start_page)
 	_cairo_ps_surface_start_page (surface);
@@ -1284,11 +1299,10 @@ _cairo_ps_surface_fill (void		*abstract_
     cairo_ps_surface_path_info_t info;
     const char *ps_operator;
 
-    if (surface->paginated_mode == CAIRO_PAGINATED_MODE_ANALYZE) {
-	if (!pattern_operation_supported (op, source))
-	    return CAIRO_INT_STATUS_UNSUPPORTED;
-	return CAIRO_STATUS_SUCCESS;
-    }
+    if (surface->paginated_mode == CAIRO_PAGINATED_MODE_ANALYZE)
+	return pattern_operation_analyze (op, source);
+
+    assert (pattern_operation_supported (op, source));
     
     if (surface->need_start_page)
 	_cairo_ps_surface_start_page (surface);
@@ -1339,11 +1353,10 @@ _cairo_ps_surface_show_glyphs (void		   
     cairo_int_status_t status;
     cairo_path_fixed_t *path;
 
-    if (surface->paginated_mode == CAIRO_PAGINATED_MODE_ANALYZE) {
-	if (!pattern_operation_supported (op, source))
-	    return CAIRO_INT_STATUS_UNSUPPORTED;
-	return CAIRO_STATUS_SUCCESS;
-    }
+    if (surface->paginated_mode == CAIRO_PAGINATED_MODE_ANALYZE)
+	return pattern_operation_analyze (op, source);
+
+    assert (pattern_operation_supported (op, source));
 
     if (surface->need_start_page)
 	_cairo_ps_surface_start_page (surface);
diff-tree 29dad9867aa5f00f4f38da5da7df6aded794682c (from 7cee03957b805db55df6f54deef5012535dfa7f4)
Author: Carl Worth <cworth at cworth.org>
Date:   Fri Mar 24 11:58:45 2006 -0800

    cairo-ps-surface: Don't support meta-surfaces. This isn't ready yet.

diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 6606992..f90a9c8 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -626,8 +626,6 @@ operator_always_translucent (cairo_opera
 static cairo_bool_t
 pattern_surface_supported (const cairo_surface_pattern_t *pattern)
 {
-    if (_cairo_surface_is_meta (pattern->surface))
-	return TRUE;
     if (pattern->surface->backend->acquire_source_image != NULL)
 	return TRUE;
     return FALSE;
diff-tree 7cee03957b805db55df6f54deef5012535dfa7f4 (from 498094027e18fbc8f190a225a87787a5b445e547)
Author: Carl Worth <cworth at cworth.org>
Date:   Fri Mar 24 11:57:18 2006 -0800

    cairo-ps-surface: Fix characterization of CLEAR and SOURCE operators.
    
    CLEAR should always be considered a translucent operator, while SOURCE is not
    necessarily always opaque.

diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index f35f823..6606992 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -562,9 +562,10 @@ operator_always_opaque (cairo_operator_t
 {
     switch (op) {
     case CAIRO_OPERATOR_CLEAR:
+	return FALSE;
 
     case CAIRO_OPERATOR_SOURCE:
-	return TRUE;
+	return FALSE;
 	
     case CAIRO_OPERATOR_OVER:
     case CAIRO_OPERATOR_IN:
@@ -594,6 +595,7 @@ operator_always_translucent (cairo_opera
 {
     switch (op) {
     case CAIRO_OPERATOR_CLEAR:
+	return TRUE;
 
     case CAIRO_OPERATOR_SOURCE:
 	return FALSE;
diff-tree 498094027e18fbc8f190a225a87787a5b445e547 (from ecb062a6792d39f7ddb670ef35ea89b868e79353)
Author: Carl Worth <cworth at cworth.org>
Date:   Fri Mar 24 11:49:48 2006 -0800

    Back out use of meta-surface for similar-paginated-surface. It's not ready yet.

diff --git a/src/cairo-paginated-surface.c b/src/cairo-paginated-surface.c
index fb56953..bb5e034 100644
--- a/src/cairo-paginated-surface.c
+++ b/src/cairo-paginated-surface.c
@@ -155,15 +155,6 @@ _cairo_paginated_surface_get_target (cai
     return paginated_surface->target;
 }
 
-static cairo_surface_t *
-_cairo_paginated_surface_create_similar (void		 *other,
-					 cairo_content_t  content,
-					 int		  width,
-					 int		  height)
-{
-    return _cairo_meta_surface_create (content, width, height);
-}
-
 static cairo_status_t
 _cairo_paginated_surface_finish (void *abstract_surface)
 {
@@ -421,7 +412,7 @@ _cairo_paginated_surface_snapshot (void 
 }
 
 const cairo_surface_backend_t cairo_paginated_surface_backend = {
-    _cairo_paginated_surface_create_similar,
+    NULL, /* create_similar */
     _cairo_paginated_surface_finish,
     _cairo_paginated_surface_acquire_source_image,
     _cairo_paginated_surface_release_source_image,
diff-tree ecb062a6792d39f7ddb670ef35ea89b868e79353 (from e2855502f2f2e701b96a2a7eee4cda8c374bcbb9)
Author: Carl Worth <cworth at cworth.org>
Date:   Fri Mar 24 11:48:35 2006 -0800

    Update PDF backend for new paginated API so it at least doesn't crash.

diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index dd2fa90..1d6eeac 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -140,6 +140,8 @@ struct cairo_pdf_surface {
     cairo_array_t alphas;
     cairo_array_t fonts;
     cairo_bool_t has_clip;
+
+    cairo_paginated_mode_t paginated_mode;
 };
 
 #define DEFAULT_DPI 300
@@ -185,6 +187,10 @@ _cairo_pdf_surface_add_stream (cairo_pdf
 static void
 _cairo_pdf_surface_ensure_stream (cairo_pdf_surface_t	*surface);
 
+static void
+_cairo_pdf_set_paginated_mode (cairo_surface_t *target,
+			       cairo_paginated_mode_t mode);
+
 static const cairo_surface_backend_t cairo_pdf_surface_backend;
 
 static unsigned int
@@ -307,7 +313,7 @@ _cairo_pdf_surface_create_for_stream_int
     return _cairo_paginated_surface_create (target,
 					    CAIRO_CONTENT_COLOR_ALPHA,
 					    width, height,
-					    NULL); /* XXX */
+					    _cairo_pdf_set_paginated_mode);
 }
 
 /**
@@ -452,6 +458,8 @@ _cairo_pdf_surface_create_for_document (
     _cairo_array_init (&surface->fonts, sizeof (cairo_pdf_resource_t));
     surface->has_clip = FALSE;
 
+    surface->paginated_mode = CAIRO_PAGINATED_MODE_ANALYZE;
+
     return &surface->base;
 }
 
@@ -2111,3 +2119,12 @@ _cairo_pdf_document_add_page (cairo_pdf_
 
     return CAIRO_STATUS_SUCCESS;
 }
+
+static void
+_cairo_pdf_set_paginated_mode (cairo_surface_t *target,
+			       cairo_paginated_mode_t paginated_mode)
+{
+    cairo_pdf_surface_t *surface = (cairo_pdf_surface_t *) target;
+
+    surface->paginated_mode = paginated_mode;
+}


More information about the cairo-commit mailing list