Bug 4172

Summary: linear-gradient fails on PPC
Product: cairo Reporter: Billy Biggs <billy.biggs>
Component: generalAssignee: Billy Biggs <billy.biggs>
Status: RESOLVED FIXED QA Contact: cairo-bugs mailing list <cairo-bugs>
Severity: minor    
Priority: high CC: cworth
Version: 0.9.3   
Hardware: x86 (IA32)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: linear-gradient-image-diff.png
Patch

Description Billy Biggs 2005-08-21 12:32:35 UTC
The linear-gradient test is failing on my PowerBook G4.  The failure occurs in
some of the diagonal gradients.  It difference seems to stem from some of the
floating point calculations in _cairo_image_data_set_linear().  The "factor"
result from this function is different between my two machines, while the input
values seem identical.
Comment 1 Billy Biggs 2005-08-21 12:38:50 UTC
In the inner loop:
  b = 0x0p+0
  qx_device = 0x1.1p+4
  d = 0x1.47ae147ae147bp-6
  qy_device = 0x1.01p+8
  ty = 0x1.699999999999ap+2

  double qy = b * qx_device + d * qy_device + ty;

PPC gives:
  qy = -0x1.051eb851eb858p-1

x86 gives:
  qy = -0x1.051eb851eb854p-1

Those are what I get using fprintf's %a, which I think should give me sufficient
precision to compare.
Comment 2 Billy Biggs 2005-08-21 12:39:33 UTC
Created attachment 2969 [details]
linear-gradient-image-diff.png
Comment 3 Billy Biggs 2005-08-21 14:02:12 UTC
Created attachment 2971 [details] [review]
Patch

Owen suggested I try changing the rounding when converting double to int, and
that worked to make the output consistent.  This patch changes cairo-pattern.c
to use the _cairo_fixed_to_double / _cairo_double_to_fixed instead of
multiplying and casting itself.  I think this change seems reasonable, and
since it fixes test failures on my Mac, even better.

However, this patch does affect the output on x86, and so the output of the
following tests will need to be updated when applied:

  gradient-alpha
  linear-gradient
  text-pattern
Comment 4 Billy Biggs 2005-08-21 14:11:07 UTC
2005-08-21  Billy Biggs  <vektor@dumbterm.net>

        Fix for bug #4172:

        * src/cairo-pattern.c: (_cairo_pattern_shader_gaussian),
        (_cairo_image_data_set_linear), (_cairo_image_data_set_radial):
        Use _cairo_fixed_to_double and _cairo_double_to_fixed when converting
        between double and 16.16 fixed point.  These functions round nicely,
        and solve some inconsistencies in rendering between my PPC and x86
        machines.  Thanks to Owen Taylor for suggesting the fix.

        * test/gradient-alpha-ref.png:
        * test/linear-gradient-ref.png:
        * test/text-pattern-ref.png: The above change does affect linear
        gradients slightly, but it seems worth it.  Update the reference
        images to follow.
Comment 5 Carl Worth 2005-08-22 17:15:45 UTC
Move bugs against "cvs" version to "0.9.3" so we can remove the "cvs" version.

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.