Bug 1491442 - Fix up and document mNeedsGLUpdate locking semantics, and remove a stray semicolon. r=mattwoodrow
authorMarkus Stange <mstange@themasta.com>
Fri, 16 Aug 2019 01:10:11 +0000
changeset 488402 82b63cd1a2d378c8ffd461b27b24a07d758be866
parent 488401 9dcce9060dac1eb0dd77b46433eb27d576311ca5
child 488403 9216803cdf01a74cb7f66632e04dae97651f3913
push id36443
push userccoroiu@mozilla.com
push dateFri, 16 Aug 2019 09:48:15 +0000
treeherdermozilla-central@5d4cbfe103bb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1491442
milestone70.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 1491442 - Fix up and document mNeedsGLUpdate locking semantics, and remove a stray semicolon. r=mattwoodrow Differential Revision: https://phabricator.services.mozilla.com/D38748
widget/cocoa/nsChildView.h
widget/cocoa/nsChildView.mm
--- a/widget/cocoa/nsChildView.h
+++ b/widget/cocoa/nsChildView.h
@@ -151,26 +151,29 @@ class WidgetRenderingContext;
   NSEvent* mClickThroughMouseDownEvent;
 
   // WheelStart/Stop events should always come in pairs. This BOOL records the
   // last received event so that, when we receive one of the events, we make sure
   // to send its pair event first, in case we didn't yet for any reason.
   BOOL mExpectingWheelStop;
 
   // Set to YES when our GL surface has been updated and we need to call
-  // updateGLContext before we composite.
+  // updateGLContext on the compositor thread before we composite.
+  // Accesses from different threads are synchronized via mGLContext's
+  // CGLContextObj lock.
   BOOL mNeedsGLUpdate;
 
   // Holds our drag service across multiple drag calls. The reference to the
   // service is obtained when the mouse enters the view and is released when
   // the mouse exits or there is a drop. This prevents us from having to
   // re-establish the connection to the service manager many times per second
   // when handling |draggingUpdated:| messages.
   nsIDragService* mDragService;
 
+  // The NSOpenGLContext that is attached to our mPixelHostingView.
   NSOpenGLContext* mGLContext;
 
   // Gestures support
   //
   // mGestureState is used to detect when Cocoa has called both
   // magnifyWithEvent and rotateWithEvent within the same
   // beginGestureWithEvent and endGestureWithEvent sequence. We
   // discard the spurious gesture event so as not to confuse Gecko.
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -2797,17 +2797,16 @@ class WidgetsReleaserRunnable final : pu
   return [[self superview] isFlipped];
 }
 
 - (BOOL)mouseDownCanMoveWindow {
   return [[self superview] mouseDownCanMoveWindow];
 }
 
 @end
-;
 
 @implementation ChildView
 
 // globalDragPboard is non-null during native drag sessions that did not originate
 // in our native NSView (it is set in |draggingEntered:|). It is unset when the
 // drag session ends for this view, either with the mouse exiting or when a drop
 // occurs in this view.
 NSPasteboard* globalDragPboard = nil;
@@ -2989,23 +2988,23 @@ NSEvent* gLastDragMouseDownEvent = nil;
   if (![self window] || ([[self window] isKindOfClass:[BaseWindow class]] &&
                          ![(BaseWindow*)[self window] isVisibleOrBeingShown] &&
                          ![(BaseWindow*)[self window] isMiniaturized])) {
     // Before the window is shown, our GL context's front FBO is not
     // framebuffer complete, so we refuse to render.
     return false;
   }
 
+  CGLLockContext((CGLContextObj)[aGLContext CGLContextObj]);
+
   if (!mGLContext) {
     mGLContext = aGLContext;
     [mGLContext retain];
-    mNeedsGLUpdate = true;
-  }
-
-  CGLLockContext((CGLContextObj)[aGLContext CGLContextObj]);
+    mNeedsGLUpdate = YES;
+  }
 
   if (mNeedsGLUpdate) {
     [self updateGLContext];
     mNeedsGLUpdate = NO;
   }
 
   return true;