Geometric vs rasterized bounding boxes

www-svg,

Current implementations return the geometric (i.e., without antialiasing)
bounding boxes for getBBox() and getStrokeBBox(). What do you think about
an API, probably an optional dictionary argument for getBBox, for accessing
the rasterized bounding box as well? Alternatively, "getAABBox" :)

In implementing getStrokeBBox() for Blink I found it difficult to compute
the rasterized bounding box for positioning a div exactly over a rendered
SVG rect. Hairline curves in Blink have special rules for aesthetics that
give different antialising values which can lead to surprising differences
between the rasterized and geometric bounding boxes. For device scale
factors that aren't 1, the rasterized bounding box could have non-integer
components.

For example:
<rect x='100' y='100' width='100' height='100' stroke-width='0.2' />
geometric stroke bounds: (x=99.8, y=99.8, width=100.4, height=100.4)
rasterized stroke bounds: (x=99, y=99, width=102, height=102)

One potential issue is whether this requires a readback on
fully-accelerated backends. I would love to hear feedback on whether this
can be efficiently implemented in IE.

For reference, the relevant spec section:
https://svgwg.org/svg2-draft/single-page.html#types-__svg__SVGGraphicsElement__getBBox

Philip

Received on Wednesday, 30 October 2013 20:37:53 UTC