[cairo] win32 surface create/destroy

Theo Veenker T.J.G.Veenker at uu.nl
Sat Apr 18 01:07:05 PDT 2009


Gerdus van Zyl wrote:
> Firstly this is off topic, you might be better served by using a
> windows api group,etc.

Excuse me, if a problem only occurs when using specific cairo functions
(and not with regular GDI) then it is not off-topic at all.

> 
> 1) The only flags I use is style = win32con.WS_THICKFRAME |
> win32con.WS_MAXIMIZEBOX | win32con.WS_MINIMIZEBOX |
> win32con.WS_SYSMENU (no CS_ flags); CS_HREDRAW and CS_VREDRAW also
> caused problems for me so I left them out and you can use
> InvalidateRect on resize message.
> 
> Also I don't think you can draw in WM_WINDOWPOSCHANGED or is at least
> bad form. The window should get the correct redraw areas, but using
> InvalidateRect you can control/add a redraw which is then handled by
> paint.

Aha, thanks. I'm not a windows programmer; I knew there had to be
something like this.

> 
> 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.

> 
> 2) Don't avoid creating and destroying a surface on paint, it's the
> generally accepted way and is recommended. If you have to use an
> ofscreen buffer,etc use cairo_create_similar or if you want double
> buffering push_group_with_content(cairo.CONTENT_COLOR) and
> cairo_pop_group

That's a pity. May I ask why it is recommended? There's a lot of code
involved creating and destroying the surface on each redraw. I don't
care about the expose and resize cases, but when doing animation I do
care about frame rate. And for each frame there's more to do then just
create/destroy a surface, so I'd like to save every possible ms.
I have to do some measurements however to see how bad it really is.

Theo



More information about the cairo mailing list