Bug 1491442 - Disable all non-CoreAnimation rendering paths when gfx.core-animation.enabled is set. r=mattwoodrow

This patch leaves you with empty windows everywhere. We will build the new
rendering paths from the ground up in the upcoming patches.

Differential Revision: https://phabricator.services.mozilla.com/D38754

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Markus Stange 2019-08-16 01:12:18 +00:00
Родитель 31bde5f08e
Коммит ca605e7b30
2 изменённых файлов: 60 добавлений и 18 удалений

Просмотреть файл

@ -159,6 +159,7 @@ class WidgetRenderingContext;
// updateGLContext on the compositor thread before we composite. // updateGLContext on the compositor thread before we composite.
// Accesses from different threads are synchronized via mGLContext's // Accesses from different threads are synchronized via mGLContext's
// CGLContextObj lock. // CGLContextObj lock.
// Always NO if StaticPrefs::gfx_core_animation_enabled_AtStartup() is true.
BOOL mNeedsGLUpdate; BOOL mNeedsGLUpdate;
// Holds our drag service across multiple drag calls. The reference to the // Holds our drag service across multiple drag calls. The reference to the
@ -169,6 +170,7 @@ class WidgetRenderingContext;
nsIDragService* mDragService; nsIDragService* mDragService;
// The NSOpenGLContext that is attached to our mPixelHostingView. // The NSOpenGLContext that is attached to our mPixelHostingView.
// Always null if StaticPrefs::gfx_core_animation_enabled_AtStartup() is true.
NSOpenGLContext* mGLContext; NSOpenGLContext* mGLContext;
// Gestures support // Gestures support
@ -204,6 +206,7 @@ class WidgetRenderingContext;
// The mask image that's used when painting into the titlebar using basic // The mask image that's used when painting into the titlebar using basic
// CGContext painting (i.e. non-accelerated). // CGContext painting (i.e. non-accelerated).
// Always null if StaticPrefs::gfx_core_animation_enabled_AtStartup() is true.
CGImageRef mTopLeftCornerMask; CGImageRef mTopLeftCornerMask;
// Subviews of self, which act as container views for vibrancy views and // Subviews of self, which act as container views for vibrancy views and
@ -212,9 +215,9 @@ class WidgetRenderingContext;
NSView* mNonDraggableViewsContainer; // [STRONG] NSView* mNonDraggableViewsContainer; // [STRONG]
// The view that does our drawing. Always non-null. // The view that does our drawing. Always non-null.
// This is a subview of self so that it can be ordered on top of // This is a subview of self so that it can be ordered on top of mVibrancyViewsContainer.
// mVibrancyViewsContainer. Drawing in this view can be performed in different // Drawing in this view can be performed in different ways:
// ways: // If StaticPrefs::gfx_core_animation_enabled_AtStartup() is false, there are two cases:
// If mUsingOMTCompositor is false, drawing is performed on the main thread // If mUsingOMTCompositor is false, drawing is performed on the main thread
// inside the view's drawRect handler. If mUsingOMTCompositor is true, // inside the view's drawRect handler. If mUsingOMTCompositor is true,
// mGLContext will be non-null and will be associated with mPixelHostingView, // mGLContext will be non-null and will be associated with mPixelHostingView,
@ -652,6 +655,7 @@ class nsChildView final : public nsBaseWidget {
// Used in BasicCompositor OMTC mode. Presents the BasicCompositor result // Used in BasicCompositor OMTC mode. Presents the BasicCompositor result
// surface to the screen using an OpenGL context. // surface to the screen using an OpenGL context.
// Always null if StaticPrefs::gfx_core_animation_enabled_AtStartup() is true.
mozilla::UniquePtr<GLPresenter> mGLPresenter; mozilla::UniquePtr<GLPresenter> mGLPresenter;
mozilla::UniquePtr<mozilla::VibrancyManager> mVibrancyManager; mozilla::UniquePtr<mozilla::VibrancyManager> mVibrancyManager;
@ -659,6 +663,7 @@ class nsChildView final : public nsBaseWidget {
mozilla::UniquePtr<mozilla::SwipeEventQueue> mSwipeEventQueue; mozilla::UniquePtr<mozilla::SwipeEventQueue> mSwipeEventQueue;
// Only used for drawRect-based painting in popups. // Only used for drawRect-based painting in popups.
// Always null if StaticPrefs::gfx_core_animation_enabled_AtStartup() is true.
RefPtr<mozilla::gfx::DrawTarget> mBackingSurface; RefPtr<mozilla::gfx::DrawTarget> mBackingSurface;
// This flag is only used when APZ is off. It indicates that the current pan // This flag is only used when APZ is off. It indicates that the current pan

Просмотреть файл

@ -249,7 +249,8 @@ static inline void FlipCocoaScreenCoordinate(NSPoint& inPoint) {
namespace { namespace {
// Used for OpenGL drawing from the compositor thread for BasicCompositor OMTC. // Used for OpenGL drawing from the compositor thread for BasicCompositor OMTC
// when StaticPrefs::gfx_core_animation_enabled_AtStartup() is false.
// This was created at a time when we didn't know how to use CoreAnimation for // This was created at a time when we didn't know how to use CoreAnimation for
// robust off-main-thread drawing. // robust off-main-thread drawing.
class GLPresenter : public GLManager { class GLPresenter : public GLManager {
@ -1350,6 +1351,8 @@ bool nsChildView::PaintWindowInDrawTarget(gfx::DrawTarget* aDT,
bool nsChildView::PaintWindowInContext(CGContextRef aContext, const LayoutDeviceIntRegion& aRegion, bool nsChildView::PaintWindowInContext(CGContextRef aContext, const LayoutDeviceIntRegion& aRegion,
gfx::IntSize aSurfaceSize) { gfx::IntSize aSurfaceSize) {
MOZ_RELEASE_ASSERT(!StaticPrefs::gfx_core_animation_enabled_AtStartup());
if (!mBackingSurface || mBackingSurface->GetSize() != aSurfaceSize) { if (!mBackingSurface || mBackingSurface->GetSize() != aSurfaceSize) {
mBackingSurface = gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget( mBackingSurface = gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(
aSurfaceSize, gfx::SurfaceFormat::B8G8R8A8); aSurfaceSize, gfx::SurfaceFormat::B8G8R8A8);
@ -1821,6 +1824,11 @@ bool nsChildView::PreRender(WidgetRenderingContext* aContext) {
bool nsChildView::PreRenderImpl(WidgetRenderingContext* aContext) { bool nsChildView::PreRenderImpl(WidgetRenderingContext* aContext) {
UniquePtr<GLManager> manager(GLManager::CreateGLManager(aContext->mLayerManager)); UniquePtr<GLManager> manager(GLManager::CreateGLManager(aContext->mLayerManager));
gl::GLContext* gl = manager ? manager->gl() : aContext->mGL; gl::GLContext* gl = manager ? manager->gl() : aContext->mGL;
if (StaticPrefs::gfx_core_animation_enabled_AtStartup()) {
return false; // This will be fleshed out in upcoming patches.
}
if (gl) { if (gl) {
return [mView preRender:GLContextCGL::Cast(gl)->GetNSOpenGLContext()]; return [mView preRender:GLContextCGL::Cast(gl)->GetNSOpenGLContext()];
} }
@ -2362,7 +2370,8 @@ void nsChildView::CleanupRemoteDrawing() {
} }
bool nsChildView::InitCompositor(Compositor* aCompositor) { bool nsChildView::InitCompositor(Compositor* aCompositor) {
if (aCompositor->GetBackendType() == LayersBackend::LAYERS_BASIC) { if (!StaticPrefs::gfx_core_animation_enabled_AtStartup() &&
aCompositor->GetBackendType() == LayersBackend::LAYERS_BASIC) {
if (!mGLPresenter) { if (!mGLPresenter) {
mGLPresenter = GLPresenter::CreateForWindow(this); mGLPresenter = GLPresenter::CreateForWindow(this);
} }
@ -2373,6 +2382,8 @@ bool nsChildView::InitCompositor(Compositor* aCompositor) {
} }
void nsChildView::DoRemoteComposition(const LayoutDeviceIntRect& aRenderRect) { void nsChildView::DoRemoteComposition(const LayoutDeviceIntRect& aRenderRect) {
MOZ_RELEASE_ASSERT(!StaticPrefs::gfx_core_animation_enabled_AtStartup());
mGLPresenter->BeginFrame(aRenderRect.Size()); mGLPresenter->BeginFrame(aRenderRect.Size());
// Draw the result from the basic compositor. // Draw the result from the basic compositor.
@ -2928,10 +2939,13 @@ NSEvent* gLastDragMouseDownEvent = nil;
name:@"AppleAquaScrollBarVariantChanged" name:@"AppleAquaScrollBarVariantChanged"
object:nil object:nil
suspensionBehavior:NSNotificationSuspensionBehaviorDeliverImmediately]; suspensionBehavior:NSNotificationSuspensionBehaviorDeliverImmediately];
if (!StaticPrefs::gfx_core_animation_enabled_AtStartup()) {
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(_surfaceNeedsUpdate:) selector:@selector(_surfaceNeedsUpdate:)
name:NSViewGlobalFrameDidChangeNotification name:NSViewGlobalFrameDidChangeNotification
object:mPixelHostingView]; object:mPixelHostingView];
}
[[NSDistributedNotificationCenter defaultCenter] [[NSDistributedNotificationCenter defaultCenter]
addObserver:self addObserver:self
@ -2983,6 +2997,8 @@ NSEvent* gLastDragMouseDownEvent = nil;
- (bool)preRender:(NSOpenGLContext*)aGLContext { - (bool)preRender:(NSOpenGLContext*)aGLContext {
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN; NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
MOZ_RELEASE_ASSERT(!StaticPrefs::gfx_core_animation_enabled_AtStartup());
if (![self window] || ([[self window] isKindOfClass:[BaseWindow class]] && if (![self window] || ([[self window] isKindOfClass:[BaseWindow class]] &&
![(BaseWindow*)[self window] isVisibleOrBeingShown] && ![(BaseWindow*)[self window] isVisibleOrBeingShown] &&
![(BaseWindow*)[self window] isMiniaturized])) { ![(BaseWindow*)[self window] isMiniaturized])) {
@ -3128,12 +3144,17 @@ NSEvent* gLastDragMouseDownEvent = nil;
return YES; return YES;
} }
// Only called if StaticPrefs::gfx_core_animation_enabled_AtStartup() is false.
- (void)updateGLContext { - (void)updateGLContext {
MOZ_RELEASE_ASSERT(!StaticPrefs::gfx_core_animation_enabled_AtStartup());
[mGLContext setView:mPixelHostingView]; [mGLContext setView:mPixelHostingView];
[mGLContext update]; [mGLContext update];
} }
- (void)_surfaceNeedsUpdate:(NSNotification*)notification { - (void)_surfaceNeedsUpdate:(NSNotification*)notification {
MOZ_RELEASE_ASSERT(!StaticPrefs::gfx_core_animation_enabled_AtStartup());
if (mGLContext) { if (mGLContext) {
CGLLockContext((CGLContextObj)[mGLContext CGLContextObj]); CGLLockContext((CGLContextObj)[mGLContext CGLContextObj]);
mNeedsGLUpdate = YES; mNeedsGLUpdate = YES;
@ -3185,6 +3206,8 @@ NSEvent* gLastDragMouseDownEvent = nil;
} }
- (LayoutDeviceIntRegion)nativeDirtyRegionWithBoundingRect:(NSRect)aRect { - (LayoutDeviceIntRegion)nativeDirtyRegionWithBoundingRect:(NSRect)aRect {
MOZ_RELEASE_ASSERT(!StaticPrefs::gfx_core_animation_enabled_AtStartup());
LayoutDeviceIntRect boundingRect = mGeckoChild->CocoaPointsToDevPixels(aRect); LayoutDeviceIntRect boundingRect = mGeckoChild->CocoaPointsToDevPixels(aRect);
const NSRect* rects; const NSRect* rects;
NSInteger count; NSInteger count;
@ -3205,7 +3228,10 @@ NSEvent* gLastDragMouseDownEvent = nil;
// The display system has told us that a portion of our view is dirty. Tell // The display system has told us that a portion of our view is dirty. Tell
// gecko to paint it // gecko to paint it
// This method is called from mPixelHostingView's drawRect handler. // This method is called from mPixelHostingView's drawRect handler.
// Only called when StaticPrefs::gfx_core_animation_enabled_AtStartup() is false.
- (void)doDrawRect:(NSRect)aRect { - (void)doDrawRect:(NSRect)aRect {
MOZ_RELEASE_ASSERT(!StaticPrefs::gfx_core_animation_enabled_AtStartup());
if (!NS_IsMainThread()) { if (!NS_IsMainThread()) {
// In the presence of CoreAnimation, this method can sometimes be called on // In the presence of CoreAnimation, this method can sometimes be called on
// a non-main thread. Ignore those calls because Gecko can only react to // a non-main thread. Ignore those calls because Gecko can only react to
@ -3273,6 +3299,8 @@ NSEvent* gLastDragMouseDownEvent = nil;
} }
- (void)setGLOpaque:(BOOL)aOpaque { - (void)setGLOpaque:(BOOL)aOpaque {
if (mGLContext) {
MOZ_RELEASE_ASSERT(!StaticPrefs::gfx_core_animation_enabled_AtStartup());
CGLLockContext((CGLContextObj)[mGLContext CGLContextObj]); CGLLockContext((CGLContextObj)[mGLContext CGLContextObj]);
// Make the context opaque for fullscreen (since it performs better), and transparent // Make the context opaque for fullscreen (since it performs better), and transparent
// for windowed (since we need it for rounded corners), but allow overriding // for windowed (since we need it for rounded corners), but allow overriding
@ -3280,10 +3308,12 @@ NSEvent* gLastDragMouseDownEvent = nil;
GLint opaque = aOpaque || StaticPrefs::gfx_compositor_glcontext_opaque(); GLint opaque = aOpaque || StaticPrefs::gfx_compositor_glcontext_opaque();
[mGLContext setValues:&opaque forParameter:NSOpenGLCPSurfaceOpacity]; [mGLContext setValues:&opaque forParameter:NSOpenGLCPSurfaceOpacity];
CGLUnlockContext((CGLContextObj)[mGLContext CGLContextObj]); CGLUnlockContext((CGLContextObj)[mGLContext CGLContextObj]);
}
} }
// Our "accelerated" windows are NSWindows which are not CoreAnimation-backed // If StaticPrefs::gfx_core_animation_enabled_AtStartup() is false, our "accelerated" windows are
// but contain an NSView with an attached NSOpenGLContext. // NSWindows which are not CoreAnimation-backed but contain an NSView with
// an attached NSOpenGLContext.
// This means such windows have two WindowServer-level "surfaces" (NSSurface): // This means such windows have two WindowServer-level "surfaces" (NSSurface):
// (1) The window's "drawRect" contents (a main-memory backed buffer) in the // (1) The window's "drawRect" contents (a main-memory backed buffer) in the
// back and // back and
@ -3388,6 +3418,10 @@ NSEvent* gLastDragMouseDownEvent = nil;
return; return;
} }
if (StaticPrefs::gfx_core_animation_enabled_AtStartup()) {
return;
}
nsAutoRetainCocoaObject kungFuDeathGrip(self); nsAutoRetainCocoaObject kungFuDeathGrip(self);
if (mGeckoChild) { if (mGeckoChild) {
@ -5899,6 +5933,9 @@ nsresult nsChildView::GetSelectionAsPlaintext(nsAString& aResult) {
} }
- (void)drawRect:(NSRect)aRect { - (void)drawRect:(NSRect)aRect {
if (StaticPrefs::gfx_core_animation_enabled_AtStartup()) {
return;
}
[(ChildView*)[self superview] doDrawRect:aRect]; [(ChildView*)[self superview] doDrawRect:aRect];
} }