[cairo] win32 surface create/destroy
Theo Veenker
T.J.G.Veenker at uu.nl
Sun Apr 19 23:59:50 PDT 2009
Vladimir Vukicevic wrote:
> On 4/18/09 1:07 AM, Theo Veenker wrote:
>>>
>>> Also CS_OWNDC is bad - see
>>> http://blogs.msdn.com/oldnewthing/archive/2006/06/01/612970.aspx
>>
>> 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
> created.
You're right. I found out I had to reset the clip region of the surface
on resize to make it work with windows that set CS_OWNDC.
>
> 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.
The overhead for create/destroy surface was about 20..50us on my system.
So not that terrible. I anyway tried to see if it would be possible to keep
the surface around (not create/destroy on each redraw). It required dropping
BeginPaint()/EndPaint() in MW_PAINT for the reasons you mention, redraw
the part indidated by GetUpdateRect() and call ValidateRect(). In the
end its no problem at all to keep the surface.
Theo
More information about the cairo
mailing list