[cairo] Hit detect surface?

Dirk Schönberger dirk.schoenberger at sz-online.de
Tue Feb 28 14:23:57 PST 2006


> This talk about GnomeCanvas needing complicated hit detection made me
> wonder if Cairo could support hit detection. This could be done with an
> entire new surface type and thus not affect any existing cairo backends.
> As I see it it would work something like this:

> 1. Program creates or reuses the hit-detect surface. This acts like an
> image surface of exactly one pixel. Program uses a surface-specific
> function to set a callback pointer.

> 2. Program adds a transformation so that the region of interest is
> transformed to the square 0,0..1,1.

> 3. Program uses any Cairo calls it wants to draw into this surface.

> 4. All attempts to modify the one pixel do the callback function, giving
> it the source color, the mask, and the op used, and possibly other
> information.

This one pixel image surface is otherwhere known as a "region". I would
assume that things like "micro-tile-arrays" (uta) provide similar
functionality.
Can this mechanism be "reversed", i.e. instead of doing all this stuff to
let cairo create he surface and communicate via callbacks, the surface is
created by the client, so that the client can access the region data
directly?
What would help is a way to create a data structure which would just store
the "on pixels", instead of the whole width x height x 1 bit bitmap.
Something like a "sparsely populated matrix", or a "micro tile array",
perhaps?

Regards
Dirk





More information about the cairo mailing list