Bug 7279 - fill/stroke_extents gives bogus result for zero width/height cases
Summary: fill/stroke_extents gives bogus result for zero width/height cases
Status: RESOLVED FIXED
Alias: None
Product: cairo
Classification: Unclassified
Component: general (show other bugs)
Version: 1.0.4
Hardware: x86 (IA32) Linux (All)
: high normal
Assignee: Carl Worth
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-06-20 05:31 UTC by Bob Gibbs
Modified: 2008-04-07 07:24 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Bob Gibbs 2006-06-20 05:31:25 UTC
The fill_extents and stroke_extents routines will return values like
32767.0, 32767.0, -32768.0, -32768.0
in cases where either the width or height of a path approaches zero.

This is not a valid result because in these cases, there are extents in one
direction but not the other.

The example below illustrates the problem.  It is written in python for brevity,
but the problem is reproduceable in c.

from cairo import *
s = ImageSurface(FORMAT_RGB24, 100, 100)
c = Context(s)
c.set_line_width(0)
c.new_path()
c.move_to(0,0)
c.line_to(100, 0)
print c.stroke_extents()
(32767.0, 32767.0, -32768.0, -32768.0)
print c.fill_extents()
(32767.0, 32767.0, -32768.0, -32768.0)

This example draws a horizontal line 100 units long.  
The results indicate:
delta_x = -32768.0 - 32767.0 = -65535.0
delta_y = -32768.0 - 32767.0 = -65535.0

I would expect:
delta_x = 100.0
delta_y = 0.0

In my use-case I have no control over when a path width or height might approach
zero, so the only thing I can do when I see the result above is iterate over the
path myself to determine the real DX/DY values.
Comment 1 Chris Wilson 2008-04-07 07:24:24 UTC
With a line width of 0, to get the values you would expect you need to use cairo_path_extents() instead of the cairo_(fill|stroke)_extents() which evaluate the bounds of the trapezoids that would be generated by cairo_(fill|stroke) respectively. cairo_path_extents() instead evaluates the bounds of the transformed path irrespective of the pen used.

The reporting of the invalid extents was itself fixed in commit 481fd3b4c8d3972ce21399f81b2021a57ed58f00.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.