[cairo] API proposal: Damage Tracking

Gerdus van Zyl gerdusvanzyl at gmail.com
Mon Dec 15 00:08:51 PST 2008


For hit detection my requirement would be all pixels with an alpha
below 25%, so some threshold value as suggested would be good. The way
i would use the api is getting the extent (rectangle) of the drawing
for a widget during render then on an event calling the widget drawing
function again this time to get pixel accurate hit detection for all
the widgets extents that matched the event.
The stack based tracking is also nice for nested widget drawing like i
am doing.

Python pseudo code of my ideal usage:
#rendering
ctx.start_tracking()
widget.renderctx(ctx)
ext_rect = ctx.tracking_extent()

#event
ctx.disable_update()
ctx.start_tracking()
widget.renderctx(ctx)
is_hit_bool = ctx.tracking_hit(x,y,alpha_threshold)
ctx.enable_update()

Which is pretty close to the api already proposed, with the exception
of "tracking_hit".

~Gerdus

On Mon, Dec 15, 2008 at 2:31 AM, Behdad Esfahbod <behdad at behdad.org> wrote:
> Bill Spitzak wrote:
>> For hit detection I think it would be better to make a hit-detecting
>> Cairo surface type, rather than adding any calls to all existing
>> surfaces. You create such a surface, draw to it, then use
>> surface-specific calls to find out what was hit.
>
> That doesn't work.  Cairo's drawing depends on the surface details (because of
> font hinting, etc).
>
>> In my experience nobody cares about the alpha of what was drawn. They
>> only want to know if the path or stroke hit a specific area, even if
>> what was drawn was a transparent image. Programs are far more interested
>> in the source x/y of a copied image that was hit, they can then (if they
>> want) look at the image to figure out if it was a transparent pixel.
>
> I don't think everyone agrees with you on this.
>
> behdad
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo
>


More information about the cairo mailing list