Bug 84115 - Broken line drawing with cairo graphics using SNA and UXA
Summary: Broken line drawing with cairo graphics using SNA and UXA
Status: RESOLVED FIXED
Alias: None
Product: cairo
Classification: Unclassified
Component: xlib backend (show other bugs)
Version: unspecified
Hardware: x86 (IA32) Linux (All)
: medium normal
Assignee: Chris Wilson
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-20 02:40 UTC by MaurizioB
Modified: 2015-06-04 21:01 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Bad strokes (1.60 KB, text/plain)
2014-09-20 06:10 UTC, Chris Wilson
Details
Eliminate precision loss when emitting spline joins (4.22 KB, patch)
2014-09-22 12:00 UTC, Chris Wilson
Details | Splinter Review
Eliminate precision loss when emitting line joins (31.48 KB, patch)
2014-09-23 07:00 UTC, Chris Wilson
Details | Splinter Review

Description MaurizioB 2014-09-20 02:40:36 UTC
As reported on cairo graphics mailing list (here: http://lists.cairographics.org/archives/cairo/2014-September/025623.html ), it looks like that the accelerated line drawing is broken while drawing arcs with cairo, and this is visible when the line width is way bigger than 1 pixel.
Using UXA the beginning of the arc is not straight, as shown here: http://jidesk.net/sypy/strangearc2.jpg
Using SNA there is also a seaming issue as shown here: http://jidesk.net/sypy/strangearc-bryce.png

After consulting users on #cairo on FreeNode, the issue is confirmed, and they suggested me to report here, since it looks like it is related to intel's X acceleration on newer drivers. I am using a i5-3570K for graphics too, which is an Ivy Bridge architecture, but I suppose that the problem affects Sandy Bridge architectures also.

Unfortunally I am no programmer, so I am just supposing a lot of things figuring out techno-babble I barely understand. I'm pretty sure that you could find the source of this issue anyway, and eventually bounce back to cairo developers if you find out that this is only a cairo related bug.

Thanks,
Maurizio
Comment 1 Chris Wilson 2014-09-20 06:09:28 UTC
The essential of the problem looks to be that the stroke geometry I create in cairo is not accurate, with the error scaling up with line width.
Comment 2 Chris Wilson 2014-09-20 06:10:56 UTC
Created attachment 106572 [details]
Bad strokes
Comment 3 Chris Wilson 2014-09-20 06:21:56 UTC
To demonstrate the problematic path:

diff --git a/src/cairo-traps-compositor.c b/src/cairo-traps-compositor.c
index 3414fc2..9618e5d 100644
--- a/src/cairo-traps-compositor.c
+++ b/src/cairo-traps-compositor.c
@@ -2188,7 +2188,7 @@ _cairo_traps_compositor_stroke (const cairo_compositor_t *_compositor,
        composite_traps_info_t info;
        unsigned flags;
 
-       if (antialias == CAIRO_ANTIALIAS_BEST || antialias == CAIRO_ANTIALIAS_GOOD) {
+       if (antialias == CAIRO_ANTIALIAS_BEST || antialias == CAIRO_ANTIALIAS_GOOD || 1) {
            func = _cairo_path_fixed_stroke_polygon_to_traps;
            flags = 0;
        } else {


i.e. _cairo_path_fixed_stroke_to_traps() is not precise enough.
Comment 4 Chris Wilson 2014-09-22 12:00:21 UTC
Created attachment 106672 [details] [review]
Eliminate precision loss when emitting spline joins
Comment 5 Chris Wilson 2014-09-23 07:00:18 UTC
Created attachment 106708 [details] [review]
Eliminate precision loss when emitting line joins

Better patch, now generates strictly correct trapezoids (i.e works with pixman as well this time)!
Comment 6 Chris Wilson 2014-09-24 11:36:51 UTC
I captured both issues with:

commit 80359e73d821516f411b25b977b442869fa5d0ad
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Tue Sep 23 12:58:27 2014 +0100

    test: Exercise stroking bugs with xlib/trapezoids
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=84115
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Comment 7 Bryce Harrington 2015-06-04 21:01:08 UTC
If I'm understanding correctly, both the test case and the fix have landed in the codebase (as commits 80359e73 and 06b9f8fa respectively), and so this bug can be closed.  Please reopen if this is incorrect.


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.