Ken Thomases : winemac: Don' t invalidate the window shadow on every draw if it' s merely shaped and not color-keyed or using per-pixel alpha.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Oct 3 03:04:12 CDT 2014


Module: wine
Branch: master
Commit: 170d80dc90fc3fb23d64f2a05f081747dd5a26c2
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=170d80dc90fc3fb23d64f2a05f081747dd5a26c2

Author: Ken Thomases <ken at codeweavers.com>
Date:   Thu Oct  2 17:06:14 2014 -0500

winemac: Don't invalidate the window shadow on every draw if it's merely shaped and not color-keyed or using per-pixel alpha.

This avoids flickering and tearing on some versions of OS X during frequent
redrawing in a shaped window, such as when scrolling a document in Word 2007.

Since we aren't guaranteed that the window surface has updated bits for us to
draw, we mark the whole content view as needing redisplay and draw the window's
shape in the background color on the first -drawRect: after the shape change.

---

 dlls/winemac.drv/cocoa_window.m | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m
index ba1b914..d9a421e 100644
--- a/dlls/winemac.drv/cocoa_window.m
+++ b/dlls/winemac.drv/cocoa_window.m
@@ -236,6 +236,17 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
         if ([window contentView] != self)
             return;
 
+        if (window.shapeChangedSinceLastDraw && window.shape && !window.colorKeyed && !window.usePerPixelAlpha)
+        {
+            [[NSColor clearColor] setFill];
+            NSRectFill(rect);
+
+            [window.shape addClip];
+
+            [[NSColor windowBackgroundColor] setFill];
+            NSRectFill(rect);
+        }
+
         if (window.surface && window.surface_mutex &&
             !pthread_mutex_lock(window.surface_mutex))
         {
@@ -289,7 +300,7 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
         // If the window may be transparent, then we have to invalidate the
         // shadow every time we draw.  Also, if this is the first time we've
         // drawn since changing from transparent to opaque.
-        if (![window isOpaque] || window.shapeChangedSinceLastDraw)
+        if (window.colorKeyed || window.usePerPixelAlpha || window.shapeChangedSinceLastDraw)
         {
             window.shapeChangedSinceLastDraw = FALSE;
             [window invalidateShadow];
@@ -1373,11 +1384,15 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
     {
         if (![self isOpaque] && !self.needsTransparency)
         {
+            self.shapeChangedSinceLastDraw = TRUE;
+            [[self contentView] setNeedsDisplay:YES];
             [self setBackgroundColor:[NSColor windowBackgroundColor]];
             [self setOpaque:YES];
         }
         else if ([self isOpaque] && self.needsTransparency)
         {
+            self.shapeChangedSinceLastDraw = TRUE;
+            [[self contentView] setNeedsDisplay:YES];
             [self setBackgroundColor:[NSColor clearColor]];
             [self setOpaque:NO];
         }




More information about the wine-cvs mailing list