[cairo] Surprising cairo_win32_printing_surface Behavior

Brent Fulgham bfulgham at gmail.com
Thu Jan 7 11:18:32 PST 2010

I've updated the test program to show a couple of more effects.  In
addition to the various Cairo test images, I now draw three final
rectangles that show the behavior I'm trying to work around:

1.  A blue rectangle is drawn with GDI onto the cairo surface.  GDI is
using an HDC retrieved as follows:

          cairo_surface_t* surface = cairo_get_target(cr);
          HDC hdc = cairo_win32_surface_get_dc(surface);

     This rectangle is clipped in the print output.

2.  A black rectangle is drawn with cairo using a cairo_t retrieved
from the HDC in item 1 (above):

          cairo_surface_t* surface = cairo_win32_surface_create(hdc);
          cairo_t* cr = cairo_create(surface);

     This rectangle is clipped in the print output.

3.  A final dashed rectangle is drawn with cairo using the same
cairo_t context used for all other drawing.
     This rectangle is drawn after all other actions have been performed.

     This rectangle is NOT clipped.

4.  I tried a final experiment where after performing all draw events,
I drew with GDI to the original passed-in HDC (avoiding the
     round trip through cairo to get at the HDC).  This rectangle was
also clipped.

Finally, just for the hell of it I tried performing the GDI drawing to
the original HDC *after* calling "cairo_show_page".

... and the rectangle was NOT clipped!

I then added a "cairo_show_page" before my other two rectangle tests
(#1 and #2).

... and the rectangles were NOT clipped.

Unfortunately, adding a few 'cairo_show_page' calls to my main program
didn't help much.  It looks like the real problem has to do with
drawing order.  Some region must be getting painted after the plugin
with either a large bounding box (that for some reason is occluding
the plugin), or something is drawing a large background placeholder
that has a higher z-order and is obscuring the plugin view.


More information about the cairo mailing list