[cairo] Re: Avoiding seams

Timothée Lecomte timothee.lecomte at ens.fr
Mon Dec 12 15:08:22 PST 2005


Hi cairo enthousiasts,

(To remind you, I am writing a cairo terminal for gnuplot to get data or
function plots, and I have performance problems with polygons. The
desired output is obtained by cairo_fill_preserve and cairo_stroke, but
it's time consuming !)

I have made some tests with my seams problems. I have successfully
written a code that inverts the order of polygons to draw them
front-to-back, on a separate cairo_t with operator SATURATE. However,
this solution raises some problems...

First, although a group of side-by-side polygons are drawn correctly
without seams, if I draw one unique polygon with this method, its edges
are not the same as with a direct draw with operator OVER. The polygon
looks like drawn inside only. For example the pixels on the horizontal
sides of the polygon are of less intensity than with operator OVER,
whereas their position is chosen to be half-integer coordinates.

Then, it adds a lot of complexity in the code : I have to store all
commands regarding color and polygons, detect when they end (ie when I
receive another type of command, for example to draw a line) and finally
sort them in a reverse order.

Last and not least, I have concluded that the solution to draw on a
separate cairo context is definitely not the right solution as far as
speed is concerned. Indeed, to respect z-order corresponding to the
order of calls given by gnuplot, there are situations where I have to
create and erase a very important number of cairo contexts. Typically,
they are situations where the calls are : "line", "polygon", "line",
"polygon", etc.

So SATURATE is not the best solution. I think that drawing at a higher
resolution has the same last problem, unless I draw everything on the
higher-resolution context.

I have followed with great interest the discussion between MenTaLguY and
Bill Spitzak about a possible new entry in the API. I am not convinced
at all by "aliased_lineto" or "aliased_curveto". It implies to detect
which sides of the polygons need to be aliased to avoid seams, and it's
not simple at all ! Moreover, I want antialiased separations between my
polygons, as they are of different colors. So, in my opinion, the new
call is more someting like "fill_and_stroke" with only the complexity of
one fill or one stroke.

Do you have any other ideas ?

Thank you very much.

Timothée Lecomte


MenTaLguY wrote:

>On Tue, 2005-11-29 at 00:30 +0100, Timothée Lecomte wrote:
>  
>
>>Because I am not sorting anything at all ! I am writing a rendering
>>plugin for gnuplot which gives me polygons back-to-front. I can store
>>gnuplot calls to invert their orders but I would prefer a more
>>straightforward solution.
>>    
>>
>I see.  It's also more memory-efficient if you can stream the rendering.
>
>Another option would be to turn off antialiasing, render at a higher
>resolution, and then filter down, giving you FSAA.
>
>-mental
>  
>



More information about the cairo mailing list