[cairo] [1.10.0] Win32 redrawing issues (regression?)

Maarten Bosmans mkbosmans at gmail.com
Fri Sep 10 15:48:13 PDT 2010

2010/9/10 Cxx Joe <cxxjoe at googlemail.com>:
> Hey,
> it's probably a mistake on my side, but I have been investigating it
> for some hours to no real avail now.
> This is what's going on:
> I'm using cairo_win32_surface_create in WM_PAINT (together with
> BeginPaint and EndPaint) to copy what I previously rendered to a
> memory image buffer to the screen device context. This includes scroll
> bar functionality.
> You can have a look at the code here:
> http://code.google.com/p/infekt/source/browse/trunk/src/win32/nfo_view_ctrl.cpp#262
> Now the problem only exists with cairo 1.10.0, 1.8.x has always been
> working fine. This is the issue:
> Whenever the invalidated rect in l_ps.rcPaint (which is equal to the
> rects in cairo_win32_surface_t->extents and
> cairo_win32_surface_t->clip_rect) has a top or left value different
> from zero, calling cairo_fill (or cairo_paint for that matter) yields
> no visible result at all. This is mostly visible when scrolling:
> Scrolling up works just fine because the invalidated rects start at
> (0,0). Scrolling down however invalidates rects at the bottom of the
> control, like (0,550)(800,620) and cairo is not painting anything to
> l_realSurface (the win32_surface) at all. This makes Windows move the
> contents above the rect to the top and keep the old content (that
> really was supposed to be painted over) at the bottom. Example:
> http://img820.imageshack.us/img820/743/fhtgfyhx.jpg
> Interestingly enough, it doesn't matter whether I'm copying the entire
> image to l_buffer (code above) or just rcPaint (code linked below).

Is it possible you are missing a few calls to cairo_surface_flush in
the right places?

Basically, whenever you are reading or writing to a surface directly,
i.e. without using cairo, you should call this function.

> Some things I have been testing to no avail:
> http://dpaste.de/mjO3/
> * Verified that drawing rectangles with GDI instead of Cairo works
> * Verified that the l_buffer memory buffer contains the correct image
> * Drawing a simple colored rect (cairo_rectangle) instead of copying
> from a buffer doesn't work either
> Can anyone think of ANYTHING that could be going on here? I looked at
> diffs from 1.8.10 to 1.10.0, I used the debugger to step through both
> versions in parallel... but I haven't been able to get to the bottom
> of this so far.

Previously cairo_surface_flush was called on every cairo_destroy, but
that behaviour was changed in 1.9.8 with this commit:

> Thanks in advance
> Joe


More information about the cairo mailing list