[cairo] cairo-cairo backend?

Helge Bahmann hcb at chaoticmind.net
Tue May 31 16:32:10 PDT 2005


Hello,

[...]
> Kristian Høgsberg has been doing the most recent investigations into
> the meta surface and his latest post on the topic can be seen here:
>
> 	http://lists.freedesktop.org/archives/cairo/2005-May/003942.html
[...]

okay; as far as I understand it a "meta-surface" would be one step further
than a "display list" -- a meta-surface has to allow inspection of the
generating drawing operations, a display list just has to support
replaying, correct? In a sense, ability to support something like display
lists is a prerequisite for meta-surfaces

[...]
> It's great to hear that you've already got some code in place. It

ahhh... it's more of a hack, using c++/stl purely because it's much
quicker to prototype in, probably leaky as well, I did not even pay
attention; I just wanted to learn the structure, see if the approach was
feasible at all and identify problems (and there are still enough)

the only change to the cairo core I did is "virtualize" stroke_path, and
it is trivial (attached, to prevent whitespace damage); I _dislike_ the
way the stroke parameters are passed around individually, I would prefer
to group them in a structure -- that would however also require
refactoring of other code paths which I wanted to avoid

but ok, since there is interest I will rewrite what I have in C,
cairo-stylize it and submit so you can have a look

[...]
> When I last gave some thought to meta surface problem, it seemed to me
> that one of the biggest pieces of new work would be efficiently
> capturing surface-based source patterns. We may need a new
> copy-on-write mechanism to keep memory needs from blowing up too much.

yes... currently I brutally copy every pattern :( not only does it waste
memory, it also prevents optimizations by backends that would like to
say "hey, I have seen this pattern already..."

Since surfaces patterns may have a specific "domain" where they live (e.g.
the xlib backend is perfectly happy with a surface pattern that lives
inside the xserver, but the display list should be ignorant about that)
this mechanism has to be backend-specific, which obviously leaves only one
place to implement it... I think I can do that, but it will take quite
some more time

I will ignore the clipping issues for the moment if someone else is
already working on it

Best regards
-- 
Helge Bahmann <hcb at chaoticmind.net>                     /| \__
The past: Smart users in front of dumb terminals       /_|____\
                                                     _/\ |   __)
$ ./configure                                        \\ \|__/__|
checking whether build environment is sane... yes     \\/___/ |
checking for AIX... no (we already did this)            |
-------------- next part --------------
diff -ur cairo-0.5.0-orig/src/cairo-gstate.c cairo-0.5.0/src/cairo-gstate.c
--- cairo-0.5.0-orig/src/cairo-gstate.c	2005-06-01 00:32:58.319548927 +0200
+++ cairo-0.5.0/src/cairo-gstate.c	2005-06-01 00:45:13.139398389 +0200
@@ -966,6 +966,18 @@
     if (gstate->line_width <= 0.0)
 	return CAIRO_STATUS_SUCCESS;
 
+    status = _cairo_surface_stroke_path (gstate->operator,
+					 gstate->source,
+					 gstate->line_width,
+					 gstate->line_cap,
+					 gstate->line_join,
+					 gstate->miter_limit,
+					 gstate->surface,
+					 path);
+    
+    if (status != CAIRO_INT_STATUS_UNSUPPORTED)
+	return status;
+    
     _cairo_pen_init (&gstate->pen_regular, gstate->line_width / 2.0, gstate);
 
     _cairo_traps_init (&traps);
diff -ur cairo-0.5.0-orig/src/cairoint.h cairo-0.5.0/src/cairoint.h
--- cairo-0.5.0-orig/src/cairoint.h	2005-06-01 00:32:58.320548845 +0200
+++ cairo-0.5.0/src/cairoint.h	2005-06-01 00:47:19.707037875 +0200
@@ -688,6 +688,15 @@
  				 cairo_pattern_t	*pattern,
  				 void			*dst,
  				 cairo_path_fixed_t	*path);
+    cairo_int_status_t
+    (*stroke_path)		(cairo_operator_t	operator,
+ 				 cairo_pattern_t	*pattern,
+ 				 double			line_width,
+ 				 cairo_line_cap_t	line_cap,
+ 				 cairo_line_join_t	line_join,
+ 				 double			miter_limit,
+ 				 void			*dst,
+ 				 cairo_path_fixed_t	*path);
    
 } cairo_surface_backend_t;
 
@@ -1442,6 +1451,16 @@
 			  cairo_surface_t    *dst,
 			  cairo_path_fixed_t *path);
   
+cairo_private cairo_int_status_t
+_cairo_surface_stroke_path (cairo_operator_t   operator,
+			    cairo_pattern_t    *pattern,
+			    double	       line_width,
+			    cairo_line_cap_t   line_cap,
+			    cairo_line_join_t  line_join,
+			    double	       miter_limit,
+			    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,
diff -ur cairo-0.5.0-orig/src/cairo-surface.c cairo-0.5.0/src/cairo-surface.c
--- cairo-0.5.0-orig/src/cairo-surface.c	2005-06-01 00:32:58.324548518 +0200
+++ cairo-0.5.0/src/cairo-surface.c	2005-06-01 00:42:41.027849865 +0200
@@ -777,6 +777,25 @@
     return CAIRO_INT_STATUS_UNSUPPORTED;
 }
 
+cairo_private cairo_int_status_t
+_cairo_surface_stroke_path (cairo_operator_t   operator,
+			    cairo_pattern_t    *pattern,
+			    double	       line_width,
+			    cairo_line_cap_t   line_cap,
+			    cairo_line_join_t  line_join,
+			    double	       miter_limit,
+			    cairo_surface_t    *dst,
+			    cairo_path_fixed_t *path)
+{
+  if (dst->backend->stroke_path)
+    return dst->backend->stroke_path (operator, pattern,
+				      line_width, line_cap, line_join,
+				      miter_limit,
+				      dst, path);
+  else
+    return CAIRO_INT_STATUS_UNSUPPORTED;
+}
+
   
 static cairo_status_t
 _fallback_composite_trapezoids (cairo_operator_t	operator,


More information about the cairo mailing list