Bug 1449271 - Add a pref called gfx.compositor.glcontext.opaque that defaults to false and can be set to true in order to force the use of an opaque OpenGL context for the window on Mac. r=jrmuizel
authorMarkus Stange <mstange@themasta.com>
Tue, 27 Mar 2018 14:43:38 -0400
changeset 463965 ae36eb8ceecaaeb9dd5c87bd651f1064fc458ae6
parent 463964 0241f894aaebeba8e8323f551f99b6f8d6017f5a
child 463966 d1b2a8d328b938d607e055f35cf028db07398f29
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1449271
milestone61.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 1449271 - Add a pref called gfx.compositor.glcontext.opaque that defaults to false and can be set to true in order to force the use of an opaque OpenGL context for the window on Mac. r=jrmuizel MozReview-Commit-ID: InOKiLXGL7o
gfx/gl/GLContextProviderCGL.mm
gfx/thebes/gfxPrefs.h
modules/libpref/init/all.js
widget/cocoa/nsChildView.mm
--- a/gfx/gl/GLContextProviderCGL.mm
+++ b/gfx/gl/GLContextProviderCGL.mm
@@ -277,18 +277,17 @@ GLContextProviderCGL::CreateForWindow(ns
     } else {
         attribs = aForceAccelerated ? kAttribs_singleBuffered_accel : kAttribs_singleBuffered;
     }
     NSOpenGLContext* context = CreateWithFormat(attribs);
     if (!context) {
         return nullptr;
     }
 
-    // make the context transparent
-    GLint opaque = 0;
+    GLint opaque = gfxPrefs::CompositorGLContextOpaque();
     [context setValues:&opaque forParameter:NSOpenGLCPSurfaceOpacity];
 
     RefPtr<GLContextCGL> glContext = new GLContextCGL(CreateContextFlags::NONE,
                                                       SurfaceCaps::ForRGBA(), context,
                                                       false);
 
     if (!glContext->Init()) {
         glContext = nullptr;
--- a/gfx/thebes/gfxPrefs.h
+++ b/gfx/thebes/gfxPrefs.h
@@ -434,16 +434,17 @@ private:
 #endif
 #if defined(RELEASE_OR_BETA)
   // "Skip" means this is locked to the default value in beta and release.
   DECL_GFX_PREF(Skip, "gfx.blocklist.all",                     BlocklistAll, int32_t, 0);
 #else
   DECL_GFX_PREF(Once, "gfx.blocklist.all",                     BlocklistAll, int32_t, 0);
 #endif
   DECL_GFX_PREF(Live, "gfx.compositor.clearstate",             CompositorClearState, bool, false);
+  DECL_GFX_PREF(Live, "gfx.compositor.glcontext.opaque",       CompositorGLContextOpaque, bool, false);
   DECL_GFX_PREF(Live, "gfx.canvas.auto_accelerate.min_calls",  CanvasAutoAccelerateMinCalls, int32_t, 4);
   DECL_GFX_PREF(Live, "gfx.canvas.auto_accelerate.min_frames", CanvasAutoAccelerateMinFrames, int32_t, 30);
   DECL_GFX_PREF(Live, "gfx.canvas.auto_accelerate.min_seconds", CanvasAutoAccelerateMinSeconds, float, 5.0f);
   DECL_GFX_PREF(Live, "gfx.canvas.azure.accelerated",          CanvasAzureAccelerated, bool, false);
   DECL_GFX_PREF(Once, "gfx.canvas.azure.accelerated.limit",    CanvasAzureAcceleratedLimit, int32_t, 0);
   // 0x7fff is the maximum supported xlib surface size and is more than enough for canvases.
   DECL_GFX_PREF(Live, "gfx.canvas.max-size",                   MaxCanvasSize, int32_t, 0x7fff);
   DECL_GFX_PREF(Once, "gfx.canvas.skiagl.cache-items",         CanvasSkiaGLCacheItems, int32_t, 256);
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -913,16 +913,20 @@ pref("gfx.webrender.enabled", true);
 #else
 pref("gfx.webrender.enabled", false);
 #endif
 #ifdef XP_WIN
 pref("gfx.webrender.force-angle", true);
 pref("gfx.webrender.program-binary", true);
 #endif
 
+#ifdef XP_MACOSX
+pref("gfx.compositor.glcontext.opaque", false);
+#endif
+
 pref("gfx.webrender.highlight-painted-layers", false);
 pref("gfx.webrender.blob-images", 1);
 pref("gfx.webrender.blob.invalidation", false);
 pref("gfx.webrender.hit-test", true);
 
 // WebRender debugging utilities.
 pref("gfx.webrender.debug.texture-cache", false);
 pref("gfx.webrender.debug.render-targets", false);
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -3845,18 +3845,19 @@ NSEvent* gLastDragMouseDownEvent = nil;
     return 4.0f;
   return [frameView roundedCornerRadius];
 }
 
 -(void)setGLOpaque:(BOOL)aOpaque
 {
   CGLLockContext((CGLContextObj)[mGLContext CGLContextObj]);
   // Make the context opaque for fullscreen (since it performs better), and transparent
-  // for windowed (since we need it for rounded corners).
-  GLint opaque = aOpaque ? 1 : 0;
+  // for windowed (since we need it for rounded corners), but allow overriding
+  // it to opaque for testing purposes, even if that breaks the rounded corners.
+  GLint opaque = aOpaque || gfxPrefs::CompositorGLContextOpaque();
   [mGLContext setValues:&opaque forParameter:NSOpenGLCPSurfaceOpacity];
   CGLUnlockContext((CGLContextObj)[mGLContext CGLContextObj]);
 }
 
 // Accelerated windows have two NSSurfaces:
 //  (1) The window's pixel buffer in the back and
 //  (2) the OpenGL view in the front.
 // These two surfaces are composited by the window manager. Drawing into the