winemac: Use CVDisplayLink to limit window redrawing to the display refresh rate.
commit3beec95a092a261f3c265fd30a10e0c0ead524bc
authorKen Thomases <ken@codeweavers.com>
Fri, 6 Nov 2015 12:57:53 +0000 (6 06:57 -0600)
committerAlexandre Julliard <julliard@winehq.org>
Fri, 6 Nov 2015 14:20:29 +0000 (6 23:20 +0900)
tree607ac021f3fa791fc6dd8c1d51e000da612442d2
parent190388ed1f449b21b7db1c6786f36fb466a779ce
winemac: Use CVDisplayLink to limit window redrawing to the display refresh rate.

Some Windows apps cause user32 to flush the window surface much faster than the
display refresh rate.  The Mac driver only marks its window as needing to be
redrawn and lets Cocoa decide how often to actually redraw.  Unfortunately,
Cocoa redraws each time through the run loop and, since the Mac driver uses a
run loop source to convey messages from background threads to the main thread,
it redraws after every batch of messages.

On some versions of OS X, this excessive drawing provokes synchronization with
the window server's buffer swaps, preventing the main thread from being
responsive.  Even when that doesn't happen, it's wasteful.

So, we set our windows' autodisplay property to false so that Cocoa never
displays windows itself.  Then, we arrange to call -displayIfNeeded once per
display refresh cycle using a CVDisplayLink.  We maintain one CVDisplayLink per
display (on demand), move windows among them as the windows change screens,
start them when they acquire their first window, and stop them when they have
none left.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
dlls/winemac.drv/Makefile.in
dlls/winemac.drv/cocoa_window.h
dlls/winemac.drv/cocoa_window.m