wxWidgets on Mac ERASE_BACKGROUND events

Ray Arachelian ray at arachelian.com
Sun May 6 11:29:23 PDT 2007


Hi,

I'm using wxWidgets for my LisaEm project ( http://lisaem.sunder.net ) but
am having a bit of trouble on the Mac side of things.

So far, what I see is that on OS X (PPC and Intel) when using wxWidgets
2.8.0 or 2.8.3 compiled to use QuickDraw (there's another problem with core
graphics in that blits look horrible), that when I send a Refresh or
RefreshRect event the erase background boolean is ignored (I set this to
false as I don't want it to be erased, but it is!)

Indeed, looking at the source code for carbon, it doesn't even use the
boolean at all.  So it's inherently assuming that the background will be
erased.

I originally thought that I needed an event.skip() in my OnErase method, but
it seems that even with that, whenever there's a region that needs to be
refreshed, either wxWidgets or the underlying OS X code clears that region
first.  On other platforms an OnErase event handler that skips works fine
and the background is left alone.

(I've gone as far as hacking up the wxWidgets carbon code to comment out the
default OnErase and dc::Clear calls, but the region is still erased, so
something underneath the ::Update() method is involved.)

My emulator draws its display to the window via Blits, and this is
expensive.  I've seen something like 500ms or more at times, so what I'm
attempting to do is update only those bits that have changed.  

The code for this works fine in that only the changes are pushed to the
screen, however, any time that I don't blit the entire display, it's cleared
out from under me and I see the Mac's usual white with horizontal stripes,
plus my changes, but not the rest of the display.  So something is indeed
doing the equivalent of an ERASE_BACKGROUND even though I don't want one.

For example, if the display is static but I move the Lisa's mouse around, I
wind up with a white window with just an updated 32x32 mouse pointer inside
of it!


So it's bad enough that I have to blit a full 720x500 bitmap which is slow,
but something else underneath it all is doing me the "favor" of erasing it
for me, thus eating up lots of CPU cycles by itself for the erase, and
causing me to use more cycles Blitting a larger area than I need to.

Is there anything I can do to prevent that?

Also, is there anything I can do to speed up Blits to the display?  1/2 a
second is a bit insane for a 700x500 bitmap - part of the reason for this is
that I do antialiasing myself since I couldn't find a better way to do it
from within wx, but if I could update just the needed portions, that would
not have been a problem.


Note that this is not the behavior I see on wxX11 under Linux, nor on
wxWin32 where OnErase is honored, and blitting just the changes works.
-- 
View this message in context: http://www.nabble.com/wxWidgets-on-Mac-ERASE_BACKGROUND-events-tf3700448.html#a10347905
Sent from the wxWidgets - Dev mailing list archive at Nabble.com.





More information about the wx-dev mailing list