Bug 1496823 - Remove -[ChildView isUsingMainThreadOpenGL] and dependent code because it always returns NO. r=spohl
authorMarkus Stange <mstange@themasta.com>
Wed, 17 Oct 2018 20:46:16 +0000
changeset 441785 8848453f27af6f3ae1538e9cbadef50bf4e95455
parent 441784 959084361b1580b3dd586b6e229e21274cc83556
child 441786 56dc11bab861326c3981f8a38f08027a2b90ae7a
push id71220
push usermstange@themasta.com
push dateWed, 17 Oct 2018 23:10:55 +0000
treeherderautoland@c9da89f17cf9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersspohl
bugs1496823, 924403
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1496823 - Remove -[ChildView isUsingMainThreadOpenGL] and dependent code because it always returns NO. r=spohl The main thread layer manager is always NONE, BASIC or CLIENT. It is never OPENGL anymore. Main-thread OpenGL rendering was removed in bug 924403. Depends on D7924 Differential Revision: https://phabricator.services.mozilla.com/D7925
widget/cocoa/nsChildView.h
widget/cocoa/nsChildView.mm
--- a/widget/cocoa/nsChildView.h
+++ b/widget/cocoa/nsChildView.h
@@ -183,18 +183,16 @@ class WidgetRenderingContext;
     eGestureState_None,
     eGestureState_StartGesture,
     eGestureState_MagnifyGesture,
     eGestureState_RotateGesture
   } mGestureState;
   float mCumulativeMagnification;
   float mCumulativeRotation;
 
-  BOOL mWaitingForPaint;
-
 #ifdef __LP64__
   // Support for fluid swipe tracking.
   BOOL* mCancelSwipeAnimation;
 #endif
 
   // Whether this uses off-main-thread compositing.
   BOOL mUsingOMTCompositor;
 
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -177,20 +177,18 @@ static NSMutableDictionary* sNativeKeyEv
 - (void) convertCocoaTabletPointerEvent:(NSEvent*)aMouseEvent
                            toGeckoEvent:(WidgetMouseEvent*)outGeckoEvent;
 - (NSMenu*)contextMenu;
 
 - (BOOL)isRectObscuredBySubview:(NSRect)inRect;
 
 - (void)drawRect:(NSRect)aRect inContext:(CGContextRef)aContext;
 - (LayoutDeviceIntRegion)nativeDirtyRegionWithBoundingRect:(NSRect)aRect;
-- (BOOL)isUsingMainThreadOpenGL;
 - (BOOL)isUsingOpenGL;
 - (void)drawUsingOpenGL;
-- (void)drawUsingOpenGLCallback;
 
 - (BOOL)hasRoundedBottomCorners;
 - (CGFloat)cornerRadius;
 - (void)clearCorners;
 
 -(void)setGLOpaque:(BOOL)aOpaque;
 
 // Overlay drawing functions for traditional CGContext drawing
@@ -3501,34 +3499,16 @@ NSEvent* gLastDragMouseDownEvent = nil;
 }
 
 - (void)setNeedsDisplayInRect:(NSRect)aRect
 {
   if (![self isUsingOpenGL]) {
     [super setNeedsDisplayInRect:aRect];
     return;
   }
-
-  if ([[self window] isVisible] && [self isUsingMainThreadOpenGL]) {
-    // Draw without calling drawRect. This prevent us from
-    // needing to access the normal window buffer surface unnecessarily, so we
-    // waste less time synchronizing the two surfaces. (These synchronizations
-    // show up in a profiler as CGSDeviceLock / _CGSLockWindow /
-    // _CGSSynchronizeWindowBackingStore.) It also means that Cocoa doesn't
-    // have any potentially expensive invalid rect management for us.
-    if (!mWaitingForPaint) {
-      mWaitingForPaint = YES;
-      // Use NSRunLoopCommonModes instead of the default NSDefaultRunLoopMode
-      // so that the timer also fires while a native menu is open.
-      [self performSelector:@selector(drawUsingOpenGLCallback)
-                 withObject:nil
-                 afterDelay:0
-                    inModes:[NSArray arrayWithObject:NSRunLoopCommonModes]];
-    }
-  }
 }
 
 - (NSString*)description
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
   return [NSString stringWithFormat:@"ChildView %p, gecko child %p, frame %@", self, mGeckoChild, NSStringFromRect([self frame])];
 
@@ -3685,22 +3665,16 @@ NSEvent* gLastDragMouseDownEvent = nil;
            aRect.origin.x, aRect.origin.y, aRect.size.width, aRect.size.height, aContext,
            geckoBounds.x, geckoBounds.y, geckoBounds.width, geckoBounds.height);
 
   CGAffineTransform xform = CGContextGetCTM(aContext);
   fprintf (stderr, "  xform in: [%f %f %f %f %f %f]\n", xform.a, xform.b, xform.c, xform.d, xform.tx, xform.ty);
 #endif
 
   if ([self isUsingOpenGL]) {
-    // For Gecko-initiated repaints in OpenGL mode, drawUsingOpenGL is
-    // directly called from a delayed perform callback - without going through
-    // drawRect.
-    // Paints that come through here are triggered by something that Cocoa
-    // controls, for example by window resizing or window focus changes.
-
     // Since this view is usually declared as opaque, the window's pixel
     // buffer may now contain garbage which we need to prevent from reaching
     // the screen. The only place where garbage can show is in the window
     // corners and the vibrant regions of the window - the rest of the window
     // is covered by opaque content in our OpenGL surface.
     // So we need to clear the pixel buffer contents in these areas.
     mGeckoChild->ClearVibrantAreas();
     [self clearCorners];
@@ -3753,56 +3727,37 @@ NSEvent* gLastDragMouseDownEvent = nil;
                             0.5);
 #endif
   CGContextSetRGBStrokeColor(aContext, 1, 0, 0, 0.8);
   CGContextSetLineWidth(aContext, 4.0);
   CGContextStrokeRect(aContext, NSRectToCGRect(aRect));
 #endif
 }
 
-- (BOOL)isUsingMainThreadOpenGL
-{
-  if (!mGeckoChild || ![self window])
-    return NO;
-
-  return mGeckoChild->GetLayerManager(nullptr)->GetBackendType() == mozilla::layers::LayersBackend::LAYERS_OPENGL;
-}
-
 - (BOOL)isUsingOpenGL
 {
   if (!mGeckoChild || ![self window])
     return NO;
 
-  return mGLContext || mUsingOMTCompositor || [self isUsingMainThreadOpenGL];
+  return mGLContext || mUsingOMTCompositor;
 }
 
 - (void)drawUsingOpenGL
 {
   AUTO_PROFILER_LABEL("ChildView::drawUsingOpenGL", OTHER);
 
   if (![self isUsingOpenGL] || !mGeckoChild->IsVisible())
     return;
 
-  mWaitingForPaint = NO;
-
   LayoutDeviceIntRect geckoBounds = mGeckoChild->GetBounds();
   LayoutDeviceIntRegion region(geckoBounds);
 
   mGeckoChild->PaintWindow(region);
 }
 
-// Called asynchronously after setNeedsDisplay in order to avoid entering the
-// normal drawing machinery.
-- (void)drawUsingOpenGLCallback
-{
-  if (mWaitingForPaint) {
-    [self drawUsingOpenGL];
-  }
-}
-
 - (BOOL)hasRoundedBottomCorners
 {
   return [[self window] respondsToSelector:@selector(bottomCornerRounded)] &&
   [[self window] bottomCornerRounded];
 }
 
 - (CGFloat)cornerRadius
 {