Bug 92202

Summary: Win32 printing surface can fail if rotation transforms are used
Product: cairo Reporter: Lee Salzman <lsalzman>
Component: win32 backendAssignee: Adrian Johnson <ajohnson>
Status: RESOLVED INVALID QA Contact: cairo-bugs mailing list <cairo-bugs>
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: Windows (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: fix rotated strokes and images in Win32 printing surfaces

Description Lee Salzman 2015-09-30 17:30:35 UTC
Created attachment 118551 [details]
fix rotated strokes and images in Win32 printing surfaces

In Firefox, we noticed that when printing a PDF including rotations from pdf.js that both images and stroked paths would fail to show up in many print drivers.

We tracked this down to two bugs in cairo-win32-printing-surface.c.

The first bug is that stroked path are both being transformed by Cairo with the CTM, and then later again by supplying the CTM to GDI when StrokePath is called. Some print drivers ignore the transform and appear to work, others honor the transform and stuff fails to work, since the path is then double-transformed. So we just removed the big about supplying the transform to GDI and all is well again.

The second bug involves image patterns. StretchDIBits under some printing devices is simply broken if you give it a rotation transform. As a simple workaround that we found worked on all printer drivers we tested with, we just swap the X and Y axes of the image before giving it to StretchDIBits, so the rotation transform becomes a harmless scale and/or mirror that the drivers will honor.

Between these two, pdf.js printing resumed working for us.

The upstream Firefox bug report is here:
http://bugzilla.mozilla.org/show_bug.cgi?id=1205854

We've attached our patch that resolves the issue and it would be nice if we could get this upstreamed.
Comment 1 Adrian Johnson 2015-10-04 12:40:50 UTC
I've added some comments to the upstream bug.

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.