Bug 1291457 - Remove shadow invalidation code. r=spohl
authorMarkus Stange <mstange@themasta.com>
Tue, 02 Aug 2016 16:39:06 -0400
changeset 596542 ae124a4dcf899adc58fe26ce67b73c22adff63e7
parent 596541 87d42add0b312998dde8ee3535aa94e602383575
child 596543 0a2aef1e3d4d98922fbb9635a761a1ca64f5efdc
push id64675
push usermak77@bonardo.net
push dateMon, 19 Jun 2017 12:08:05 +0000
reviewersspohl
bugs1291457
milestone56.0a1
Bug 1291457 - Remove shadow invalidation code. r=spohl Invalidating a window's shadow is really slow and leads to flickering. Now that arrow panels don't change their contents during the panel opening animation any more, their shape stays the same after the first paint, so we don't need the shadow invalidation functionality for them any more. And as far as I know, we don't use transparent popups with changing shapes anywhere else. The system still computes the shadow for the first paint of the window (which happens during the orderFront call), and it updates the shadow whenever the window resizes. But not when its size stays the same and only what we draw in the content is updated. MozReview-Commit-ID: 138PjbrSFrc
widget/cocoa/nsChildView.mm
widget/cocoa/nsCocoaWindow.h
widget/cocoa/nsCocoaWindow.mm
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -3762,22 +3762,16 @@ NSEvent* gLastDragMouseDownEvent = nil;
 }
 
 // The display system has told us that a portion of our view is dirty. Tell
 // gecko to paint it
 - (void)drawRect:(NSRect)aRect
 {
   CGContextRef cgContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
   [self drawRect:aRect inContext:cgContext];
-
-  // If we're a transparent window and our contents have changed, we need
-  // to make sure the shadow is updated to the new contents.
-  if ([[self window] isKindOfClass:[BaseWindow class]]) {
-    [(BaseWindow*)[self window] deferredInvalidateShadow];
-  }
 }
 
 - (void)drawRect:(NSRect)aRect inContext:(CGContextRef)aContext
 {
   if (!mGeckoChild || !mGeckoChild->IsVisible())
     return;
 
 #ifdef DEBUG_UPDATE
--- a/widget/cocoa/nsCocoaWindow.h
+++ b/widget/cocoa/nsCocoaWindow.h
@@ -36,19 +36,16 @@ typedef struct _nsCocoaWindowList {
 @interface BaseWindow : NSWindow
 {
   // Data Storage
   NSMutableDictionary* mState;
   BOOL mDrawsIntoWindowFrame;
   NSColor* mActiveTitlebarColor;
   NSColor* mInactiveTitlebarColor;
 
-  // Shadow
-  BOOL mScheduledShadowInvalidation;
-
   // Invalidation disabling
   BOOL mDisabledNeedsDisplay;
 
   // DPI cache. Getting the physical screen size (CGDisplayScreenSize)
   // is ridiculously slow, so we cache it in the toplevel window for all
   // descendants to use.
   float mDPI;
 
@@ -64,18 +61,16 @@ typedef struct _nsCocoaWindowList {
 
 - (void)importState:(NSDictionary*)aState;
 - (NSMutableDictionary*)exportState;
 - (void)setDrawsContentsIntoWindowFrame:(BOOL)aState;
 - (BOOL)drawsContentsIntoWindowFrame;
 - (void)setTitlebarColor:(NSColor*)aColor forActiveWindow:(BOOL)aActive;
 - (NSColor*)titlebarColorForActiveWindow:(BOOL)aActive;
 
-- (void)deferredInvalidateShadow;
-- (void)invalidateShadow;
 - (float)getDPI;
 
 - (void)mouseEntered:(NSEvent*)aEvent;
 - (void)mouseExited:(NSEvent*)aEvent;
 - (void)mouseMoved:(NSEvent*)aEvent;
 - (void)updateTrackingArea;
 - (NSView*)trackingAreaView;
 
--- a/widget/cocoa/nsCocoaWindow.mm
+++ b/widget/cocoa/nsCocoaWindow.mm
@@ -2995,17 +2995,16 @@ static NSMutableSet *gSwizzledFrameViewC
 
 - (id)initWithContentRect:(NSRect)aContentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)aBufferingType defer:(BOOL)aFlag
 {
   mDrawsIntoWindowFrame = NO;
   [super initWithContentRect:aContentRect styleMask:aStyle backing:aBufferingType defer:aFlag];
   mState = nil;
   mActiveTitlebarColor = nil;
   mInactiveTitlebarColor = nil;
-  mScheduledShadowInvalidation = NO;
   mDisabledNeedsDisplay = NO;
   mDPI = GetDPI(self);
   mTrackingArea = nil;
   mDirtyRect = NSZeroRect;
   mBeingShown = NO;
   mDrawTitle = NO;
   mBrightTitlebarForeground = NO;
   mUseMenuStyle = NO;
@@ -3145,31 +3144,16 @@ static const NSString* kStateCollectionB
   }
 }
 
 - (NSColor*)titlebarColorForActiveWindow:(BOOL)aActive
 {
   return aActive ? mActiveTitlebarColor : mInactiveTitlebarColor;
 }
 
-- (void)deferredInvalidateShadow
-{
-  if (mScheduledShadowInvalidation || [self isOpaque] || ![self hasShadow])
-    return;
-
-  [self performSelector:@selector(invalidateShadow) withObject:nil afterDelay:0];
-  mScheduledShadowInvalidation = YES;
-}
-
-- (void)invalidateShadow
-{
-  [super invalidateShadow];
-  mScheduledShadowInvalidation = NO;
-}
-
 - (float)getDPI
 {
   return mDPI;
 }
 
 - (NSView*)trackingAreaView
 {
   NSView* contentView = [self contentView];