[XRender] Howto draw a hairline-trapezoid?
Glynn Clements
glynn at gclements.plus.com
Mon Jun 2 06:38:09 PDT 2008
Clemens Eisserer wrote:
> I have some troubles replacing XDrawLine with XRender code.
>
> XDrawLine seems to take care that the line "appears" 1px wide, whereas
> XRender does (mathematically correct) draw overlapping line segments,
> which looks like the 1px line has not a constant width.
>
> I created two demos which show the difference:
> http://picasaweb.google.com/linuxhippy/Cairo/photo#5207262578956837426
>
> The first circle was done using XDrawLine, the second with plain
> XRender (Cairo showed the same problems).
>
> Any idea how I could mimic the "old" XDrawLine behaviour with XRender?
What line width are you using for XDrawLine()? Zero or one?
The rendering of zero-width lines by XDrawLine() can vary between
drivers. The XChangeGC() manual page says:
Thin lines (zero line-width) are one-pixel-wide lines drawn using an
unspecified, device-dependent algorithm. There are only two con-
straints on this algorithm.
1. If a line is drawn unclipped from [x1,y1] to [x2,y2] and if
another line is drawn unclipped from [x1+dx,y1+dy] to
[x2+dx,y2+dy], a point [x,y] is touched by drawing the first line
if and only if the point [x+dx,y+dy] is touched by drawing the
second line.
2. The effective set of points comprising a line cannot be affected
by clipping. That is, a point is touched in a clipped line if and
only if the point lies inside the clipping region and the point
would be touched by the line when drawn unclipped.
A wide line drawn from [x1,y1] to [x2,y2] always draws the same pixels
as a wide line drawn from [x2,y2] to [x1,y1], not counting cap-style
and join-style. It is recommended that this property be true for thin
lines, but this is not required. A line-width of zero may differ from
a line-width of one in which pixels are drawn. This permits the use of
many manufacturers' line drawing hardware, which may run many times
faster than the more precisely specified wide lines.
--
Glynn Clements <glynn at gclements.plus.com>
More information about the xorg
mailing list