[cairo] win32 surface create/destroy
vladimir at pobox.com
Sun Apr 19 12:18:10 PDT 2009
On 4/18/09 1:07 AM, Theo Veenker wrote:
>> Also CS_OWNDC is bad - see
> Good to know. I'll just drop CS_OWNDC, as it just makes things worse.
For the CS_OWNDC case, the system is modifying that DC behind cairo's
back -- while a cairo surface is attached to the DC, it's generally bad
to use GDI on that same DC unless you return things back to the same
state that they were in before making a cairo call. In particular, the
bounds on the DC are inferred by examining the clip region attached to
the DC at surface creation time; I believe this clip region will change
in BeginPaint as the system clips to the dirty areas, but cairo won't
know that and will still use the clip that was set when the surface was
This is also why you should create a new surface each time when
interacting with a platform-native drawing system -- unless you have
permanent control over something like a DC, you need to take care to not
have cairo and native drawing clash with eachother.
If your rendering is complex enough, you may get a performance boost by
using an image surface that you keep around, resizing the surface when
the window size changes only; and then using StretchDIBits to draw that
to the window in WM_PAINT.
More information about the cairo