[cairo-commit] cairo/src cairo-gstate.c, 1.119, 1.120 cairo-path.c, 1.26, 1.27 cairo-pdf-surface.c, 1.30, 1.31 cairo-surface.c, 1.62, 1.63 cairoint.h, 1.132, 1.133

Kristian Hogsberg commit at pdx.freedesktop.org
Tue May 3 14:28:52 PDT 2005


Committed by: krh

Update of /cvs/cairo/cairo/src
In directory gabe:/tmp/cvs-serv24435/src

Modified Files:
	cairo-gstate.c cairo-path.c cairo-pdf-surface.c 
	cairo-surface.c cairoint.h 
Log Message:
2005-05-03  Kristian Høgsberg  <krh at redhat.com>

        Fills as paths patch originally by Owen Taylor.

        * src/cairo-path.c: (_cairo_path_fixed_rel_move_to),
        (_cairo_path_fixed_line_to), (_cairo_path_fixed_rel_line_to),
        (_cairo_path_fixed_curve_to), (_cairo_path_fixed_rel_curve_to):
        Make sure we have a current point for the relative path operators.

        * src/cairoint.h:
        * src/cairo-gstate.c: (_cairo_gstate_fill):
        * src/cairo-surface.c: (_cairo_surface_fill_path): Add fill_path
        backend method.

        * src/cairo-pdf-surface.c: (_cairo_pdf_document_close_stream),
        (emit_image_data), (emit_surface_pattern),
        (_cairo_pdf_path_move_to), (_cairo_pdf_path_line_to),
        (_cairo_pdf_path_curve_to), (_cairo_pdf_path_close_path),
        (_cairo_pdf_surface_fill_path): Implement fill_path in the PDF
        backend.



Index: cairo-gstate.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-gstate.c,v
retrieving revision 1.119
retrieving revision 1.120
diff -u -d -r1.119 -r1.120
--- cairo-gstate.c	3 May 2005 15:33:32 -0000	1.119
+++ cairo-gstate.c	3 May 2005 21:28:50 -0000	1.120
@@ -1443,7 +1443,15 @@
 
     if (gstate->surface->level != gstate->surface_level)
 	return CAIRO_STATUS_BAD_NESTING;
+
+    status = _cairo_surface_fill_path (gstate->operator,
+				       gstate->source,
+				       gstate->surface,
+				       path);
     
+    if (status != CAIRO_INT_STATUS_UNSUPPORTED)
+	return status;
+
     _cairo_traps_init (&traps);
 
     status = _cairo_path_fixed_fill_to_traps (path, gstate, &traps);

Index: cairo-path.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-path.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- cairo-path.c	2 May 2005 19:36:20 -0000	1.26
+++ cairo-path.c	3 May 2005 21:28:50 -0000	1.27
@@ -184,6 +184,9 @@
 {
     cairo_fixed_t x, y;
 
+    if (!path->has_current_point)
+	return CAIRO_STATUS_NO_CURRENT_POINT;
+
     x = path->current_point.x + dx;
     y = path->current_point.y + dy;
 
@@ -218,6 +221,9 @@
 {
     cairo_fixed_t x, y;
 
+    if (!path->has_current_point)
+	return CAIRO_STATUS_NO_CURRENT_POINT;
+
     x = path->current_point.x + dx;
     y = path->current_point.y + dy;
 
@@ -257,6 +263,9 @@
     cairo_fixed_t x1, y1;
     cairo_fixed_t x2, y2;
 
+    if (!path->has_current_point)
+	return CAIRO_STATUS_NO_CURRENT_POINT;
+
     x0 = path->current_point.x + dx0;
     y0 = path->current_point.y + dy0;
 

Index: cairo-pdf-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-pdf-surface.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- cairo-pdf-surface.c	19 Apr 2005 23:29:05 -0000	1.30
+++ cairo-pdf-surface.c	3 May 2005 21:28:50 -0000	1.31
@@ -1077,7 +1077,6 @@
     length = _cairo_output_stream_get_position (output_stream) -
 	stream->start_offset;
     _cairo_output_stream_printf (output_stream,
-				 "\r\n"
 				 "endstream\r\n"
 				 "endobj\r\n");
 
@@ -1206,6 +1205,8 @@
 
     stream = _cairo_pdf_document_open_stream (document, entries);
     _cairo_output_stream_write (output, compressed, compressed_size);
+    _cairo_output_stream_printf (output,
+				 "\r\n");
     _cairo_pdf_document_close_stream (document);
 
     free (rgb);
@@ -1429,16 +1430,14 @@
 	      "   /PatternType 1\r\n"
 	      "   /TilingType 1\r\n"
 	      "   /PaintType 1\r\n"
-	      "   /Resources << /XObject << /res%d %d 0 R >> >>\r\n"
-	      "   /Matrix [ %f %f %f %f %f %f ]\r\n",
-	      id, id,
-	      pm.xx, pm.yx,
-	      pm.xy, pm.yy,
-	      pm.x0, pm.y0);
+	      "   /Resources << /XObject << /res%d %d 0 R >> >>\r\n",
+	      id, id);
 
     stream = _cairo_pdf_document_open_stream (document, entries);
 
-    /* FIXME: emit code to show surface here. */
+    _cairo_output_stream_printf (output,
+				 " /res%d Do\r\n",
+				 id);
 
     _cairo_pdf_surface_add_pattern (dst, stream->id);
 
@@ -1642,6 +1641,104 @@
 	_cairo_fixed_to_double (line->p2.y - line->p1.y);
 }
 
+typedef struct
+{
+    cairo_output_stream_t *output_stream;
+} pdf_path_info_t;
+
+static cairo_status_t
+_cairo_pdf_path_move_to (void *closure, cairo_point_t *point)
+{
+    pdf_path_info_t *info = closure;
+
+    _cairo_output_stream_printf (info->output_stream,
+				 "%f %f m ",
+				 _cairo_fixed_to_double (point->x),
+				 _cairo_fixed_to_double (point->y));
+    
+    return CAIRO_STATUS_SUCCESS;
+}
+
+static cairo_status_t
+_cairo_pdf_path_line_to (void *closure, cairo_point_t *point)
+{
+    pdf_path_info_t *info = closure;
+    
+    _cairo_output_stream_printf (info->output_stream,
+				 "%f %f l ",
+				 _cairo_fixed_to_double (point->x),
+				 _cairo_fixed_to_double (point->y));
+
+    return CAIRO_STATUS_SUCCESS;
+}
+
+static cairo_status_t
+_cairo_pdf_path_curve_to (void          *closure,
+			  cairo_point_t *b,
+			  cairo_point_t *c,
+			  cairo_point_t *d)
+{
+    pdf_path_info_t *info = closure;
+
+    _cairo_output_stream_printf (info->output_stream,
+				 "%f %f %f %f %f %f c ",
+				 _cairo_fixed_to_double (b->x),
+				 _cairo_fixed_to_double (b->y),
+				 _cairo_fixed_to_double (c->x),
+				 _cairo_fixed_to_double (c->y),
+				 _cairo_fixed_to_double (d->x),
+				 _cairo_fixed_to_double (d->y));
+    
+    return CAIRO_STATUS_SUCCESS;
+}
+
+static cairo_status_t
+_cairo_pdf_path_close_path (void *closure)
+{
+    pdf_path_info_t *info = closure;
+    
+    _cairo_output_stream_printf (info->output_stream,
+				 "h\r\n");
+
+    return CAIRO_STATUS_SUCCESS;
+}
+
+static cairo_int_status_t
+_cairo_pdf_surface_fill_path (cairo_operator_t		operator,
+			      cairo_pattern_t		*pattern,
+			      void			*abstract_dst,
+			      cairo_path_fixed_t	*path)
+{
+    cairo_pdf_surface_t *surface = abstract_dst;
+    cairo_pdf_document_t *document = surface->document;
+    cairo_status_t status;
+    pdf_path_info_t info;
+
+    return CAIRO_INT_STATUS_UNSUPPORTED;
+
+    emit_pattern (surface, pattern);
+
+    /* After the above switch the current stream should belong to this
+     * surface, so no need to _cairo_pdf_surface_ensure_stream() */
+    assert (document->current_stream != NULL &&
+	    document->current_stream == surface->current_stream);
+
+    info.output_stream = document->output_stream;
+
+    status = _cairo_path_fixed_interpret (path,
+					  CAIRO_DIRECTION_FORWARD,
+					  _cairo_pdf_path_move_to,
+					  _cairo_pdf_path_line_to,
+					  _cairo_pdf_path_curve_to,
+					  _cairo_pdf_path_close_path,
+					  &info);
+
+    _cairo_output_stream_printf (document->output_stream,
+				 "f\r\n");
+
+    return status;
+}
+  
 static cairo_int_status_t
 _cairo_pdf_surface_composite_trapezoids (cairo_operator_t	operator,
 					 cairo_pattern_t	*pattern,
@@ -1827,7 +1924,8 @@
     _cairo_pdf_surface_show_page,
     NULL, /* set_clip_region */
     _cairo_pdf_surface_get_extents,
-    _cairo_pdf_surface_show_glyphs
+    _cairo_pdf_surface_show_glyphs,
+    _cairo_pdf_surface_fill_path
 };
 
 static cairo_pdf_document_t *

Index: cairo-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-surface.c,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- cairo-surface.c	2 May 2005 20:39:33 -0000	1.62
+++ cairo-surface.c	3 May 2005 21:28:50 -0000	1.63
@@ -844,6 +844,19 @@
     return _fallback_fill_rectangles (surface, operator, color, rects, num_rects);
 }
 
+cairo_private cairo_int_status_t
+_cairo_surface_fill_path (cairo_operator_t   operator,
+			  cairo_pattern_t    *pattern,
+			  cairo_surface_t    *dst,
+			  cairo_path_fixed_t *path)
+{
+  if (dst->backend->fill_path)
+    return dst->backend->fill_path (operator, pattern, dst, path);
+  else
+    return CAIRO_INT_STATUS_UNSUPPORTED;
+}
+
+  
 static cairo_status_t
 _fallback_composite_trapezoids (cairo_operator_t	operator,
 				cairo_pattern_t		*pattern,

Index: cairoint.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairoint.h,v
retrieving revision 1.132
retrieving revision 1.133
diff -u -d -r1.132 -r1.133
--- cairoint.h	2 May 2005 20:39:33 -0000	1.132
+++ cairoint.h	3 May 2005 21:28:50 -0000	1.133
@@ -680,6 +680,13 @@
 				 unsigned int			 height,
 				 const cairo_glyph_t		*glyphs,
 				 int				 num_glyphs);
+
+    cairo_int_status_t
+    (*fill_path)		(cairo_operator_t	operator,
+ 				 cairo_pattern_t	*pattern,
+ 				 void			*dst,
+ 				 cairo_path_fixed_t	*path);
+   
 } cairo_surface_backend_t;
 
 typedef struct _cairo_format_masks {
@@ -1434,6 +1441,12 @@
 				cairo_rectangle_t	*rects,
 				int			num_rects);
 
+cairo_private cairo_int_status_t
+_cairo_surface_fill_path (cairo_operator_t   operator,
+			  cairo_pattern_t    *pattern,
+			  cairo_surface_t    *dst,
+			  cairo_path_fixed_t *path);
+  
 cairo_private cairo_status_t
 _cairo_surface_composite_trapezoids (cairo_operator_t	operator,
 				     cairo_pattern_t	*pattern,




More information about the cairo-commit mailing list