Re: Problem with directly drawing to a GDI context

Maarten Bosmans <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <CA+CvcKS=4N7Y2zMuOYU4ipKX5+98BogMNJZQ+q4HJY+B8qwm2w@mail.gmail.com>
2011/8/25 Andrej Mitrovic <[email protected]>:
> Here's a simple example of drawing with either GDI, cairo directly to
> a device context, and cairo to a memory buffer:
>
> http://codepad.org/BVJ6hOjU
>
> If I use the FillGDI() function and try to move another window on top
> of the app, the app's client area that becomes visible is filled with
> blue and there's no issues.
>
> However If I use FillCairo(), I have this issue: http://i.imgur.com/87BUf.png
>
> This problem goes away if I use cairo to draw into a memory buffer and
> then blit to the device context, in this case I use BufferFillCairo().
>
> Is this some kind of a bug or do I always have to use a memory buffer
> when drawing with cairo?

I don't have any direct answers to your questions, but I do have some pointers.

In general I find that drawing to an image surface with cairo and
blitting to the screen is much faster than using cairo's win32 backend
directly to draw on screen. It's simply that pixman does such a good
job compared to the ancient GDI subsystem.

Make sure you're not affected by this bug:
https://bugs.freedesktop.org/show_bug.cgi?id=28541

Also (even when your example code seems to create a new surface every
time, so not really applicable, but anyway) remember that when
combining cairo drawing with calls to the underling native system (GDI
in this case) need to be protected by cairo_surface_flush and
cairo_surface_mark_dirty.

Maarten

> If I disable redrawing of the entire background (by returning 1 in the
> WM_ERASEBKGND message), the effect is similar:
> http://i.imgur.com/ns1xB.png
> And again in that case the FillGDI and BufferFillCairo functions work
> fine, but FillCairo() has these issues.
> --
> cairo mailing list
> [email protected]
> http://lists.cairographics.org/mailman/listinfo/cairo
>
--
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.