[cairo] shading, take 2
David Reveman
c99drn at cs.umu.se
Fri Mar 5 00:33:16 PST 2004
I did the same thing with the current OpenGL backend patch. It's funny
how similar our solutions are, but I guess thats good, maybe it proves
that the solution is good.
I'm off course not suggesting that we should use my solution instead but
I think you should take a look at it.
Some things are different:
I use a cairo_shader_t type instead of cairo_pattern_t (like your choice
much better, so stick with that).
I never dynamically allocated shaders (I think you should do the same
with your cairo_pattern_t).
The OpenGL backend can accelerate all shaders even solid ones. This
should be just as easy to support in your solution as mine but it might
be good that you take a look at my code so that we are sure that no
problems may arise later on.
Get the lates gl backend patch from:
http://www.cs.umu.se/~c99drn/
/ David
On Wed, 2004-03-03 at 16:21 +0100, Thomas Hunger wrote:
> Hi
> Based on the ideas discussed here I refactored cairo a bit to implement
> shading.
> Each backend has now a create_pattern callback which takes a cairo_pattern_t
> and the dimensions of the expected image. It may then either fill it or
> return NULL which starts a software shader (again, only linear so far, radial
> is in work, others would be nice, suggestions welcome) which returns the
> wanted image.
> since solid color and bitmaps are patterns, too, I plugged them into the
> cairo_pattern_t.
> This function now replaces the ensure_source function which was used by cairo
> before.
> Patterns may have an etxra transformation matrix set which maps to different
> purposes:
>
> set_pattern: sets the surface matrix before surface is composited (1)
> set_pattern_linear|radial: transforms the control points
>
> colors are controlled via
>
> void
> cairo_pattern_add_color_stop (cairo_t *cr, double offset, double r, double g,
> double b, double a);
>
> which should work for linear shaders. Like in svg offset has to be a value
> between 0 and 1.
>
> In svg different models are supported when the offset goes behind 1: pad,
> mirror and repeat. currently the linear shader only pads, but the other
> functions are in work.
>
> The surface matrix is now part of the pattern state (see (1)), the functions
> cairo_surface_set_matrix, repeat, filter have moved to the private api. this
> breaks at least one cairo-demo so far (knockout)
>
> Since shader and maybe the user want to know which rectangular area is
> covered by a fill or stroke operation the following functions have moved into
> the public api:
>
> void
> cairo_stroke_extents (cairo_t *cr, pixman_box16_t *extents);
> void
> cairo_fill_extents (cairo_t *cr, pixman_box16_t *extents);
>
> This implements one part of functionality proposed by Carl Worth in this mail:
> http://www.cairographics.org/pipermail/cairo/2003-October/000689.html
>
> This is only a quick overview, not all work is done yet, but I would be happy
> about comments. The names of the functions can easily be changed if you are
> unhappy with them (I did not waste much time to make them up).
>
> some screenshots and a tarball can be found here:
> http://www.iqo.uni-hannover.de/gnome/cairo/
>
> Tom
>
> P.S. is there acutally transparency in svg? I searched but could not find
> it...
>
>
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://cairographics.org/cgi-bin/mailman/listinfo/cairo
--
David Reveman <c99drn at cs.umu.se>
More information about the cairo
mailing list