[cairo] CAIRO_BO_GUARD_BITS and coordinate space?

Vladimir Vukicevic vladimir at pobox.com
Mon Dec 4 00:22:23 PST 2006

I just merged in the latest git tip into mozilla, and now have a pile of 
assertion failures in the new tessellator.  I'm hitting one of the two 
assertions in _cairo_bo_event_queue_init:

	/* We must not be given horizontal edges. */
	assert (edges[i].top.y != edges[i].bottom.y);

	/* We also must not be given any upside-down edges. */
	assert (_cairo_bo_point32_compare (&edges[i].top, &edges[i].bottom) < 0);

The problem seems to be that in 
_cairo_bentley_ottmann_tessellate_bo_edges, the input edge coordinates 
are left-shifted by CAIRO_BO_GUARD_BITS, which is 2.  But 
cairo_bo_edge_t contans cairo_bo_point32_t's, which are just 32-bit 
fixed types.  So that shift ends up destroying the 2 highest bits -- 
reducing the potential coordinate space from 16 bits to 14 bits.  This 
seems pretty bogus -- should those be 64-bit types there?

The following code triggers the assertion:

    cairo_rectangle(cr, 0., 0., 100., 16384.);

16384.0 turns into 0x40000000, left-shifted by 2 turns in to 
0x00000000...  I'm hitting both assertions depending on the input, 
because some numbers end up completely wrong (e.g. positive numbers turn 
in to negative numbers, etc., thus flipping the edge).

What's going on here?  We were able to use coordinates up to 32766 
before the new tessellator, now we're down to 8192?

     - Vlad

More information about the cairo mailing list