Bug 1279657 - failureId outvar should be a pointer. - r=benwa
authorJeff Gilbert <jgilbert@mozilla.com>
Fri, 10 Jun 2016 19:01:00 -0700
changeset 332099 aa737095008decf8aa4fc4d8d368a4f7cb7ca198
parent 332098 9c693bcd071c9b293405cd4d42a79d66531edb79
child 332100 fcd860b7546f72dfbc95dff5f0fc443b244485b1
push idunknown
push userunknown
push dateunknown
reviewersbenwa
bugs1279657
milestone50.0a1
Bug 1279657 - failureId outvar should be a pointer. - r=benwa MozReview-Commit-ID: 4s0OqZcHno5
dom/canvas/WebGLContext.cpp
gfx/gl/GLContextEGL.h
gfx/gl/GLContextProviderCGL.mm
gfx/gl/GLContextProviderEGL.cpp
gfx/gl/GLContextProviderGLX.cpp
gfx/gl/GLContextProviderImpl.h
gfx/gl/GLContextProviderNull.cpp
gfx/gl/GLContextProviderWGL.cpp
gfx/gl/GLLibraryEGL.cpp
gfx/gl/GLLibraryEGL.h
gfx/layers/GLImages.cpp
gfx/layers/opengl/CompositorOGL.cpp
gfx/tests/gtest/TestCompositor.cpp
gfx/thebes/gfxPlatform.cpp
--- a/dom/canvas/WebGLContext.cpp
+++ b/dom/canvas/WebGLContext.cpp
@@ -581,17 +581,17 @@ BaseCaps(const WebGLContextOptions& opti
 
 static already_AddRefed<gl::GLContext>
 CreateGLWithEGL(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
                 WebGLContext* webgl, nsACString* const out_failReason,
                 nsACString* const out_failureId)
 {
     const gfx::IntSize dummySize(16, 16);
     RefPtr<GLContext> gl = gl::GLContextProviderEGL::CreateOffscreen(dummySize, caps,
-                                                                     flags, *out_failureId);
+                                                                     flags, out_failureId);
     if (gl && gl->IsANGLE()) {
         gl = nullptr;
     }
 
     if (!gl) {
         if (out_failReason->Length()) {
             out_failReason->AppendLiteral("\n");
         }
@@ -607,17 +607,17 @@ CreateGLWithEGL(const gl::SurfaceCaps& c
 
 static already_AddRefed<GLContext>
 CreateGLWithANGLE(const gl::SurfaceCaps& caps, gl::CreateContextFlags flags,
                   WebGLContext* webgl, nsACString* const out_failReason,
                   nsACString* const out_failureId)
 {
     const gfx::IntSize dummySize(16, 16);
     RefPtr<GLContext> gl = gl::GLContextProviderEGL::CreateOffscreen(dummySize, caps,
-                                                                     flags, *out_failureId);
+                                                                     flags, out_failureId);
     if (gl && !gl->IsANGLE()) {
         gl = nullptr;
     }
 
     if (!gl) {
         if (out_failReason->Length()) {
             out_failReason->AppendLiteral("\n");
         }
@@ -646,17 +646,17 @@ CreateGLWithDefault(const gl::SurfaceCap
         }
         out_failReason->AppendASCII("Refused to create native OpenGL context because of"
                                     " blacklisting.");
         return nullptr;
     }
 
     const gfx::IntSize dummySize(16, 16);
     RefPtr<GLContext> gl = gl::GLContextProvider::CreateOffscreen(dummySize, caps,
-                                                                  flags, *out_failureId);
+                                                                  flags, out_failureId);
 
     if (gl && gl->IsANGLE()) {
         gl = nullptr;
     }
 
     if (!gl) {
         if (out_failReason->Length()) {
             out_failReason->AppendASCII("\n");
--- a/gfx/gl/GLContextEGL.h
+++ b/gfx/gl/GLContextEGL.h
@@ -19,17 +19,17 @@ class GLContextEGL : public GLContext
 
     static already_AddRefed<GLContextEGL>
     CreateGLContext(CreateContextFlags flags,
                     const SurfaceCaps& caps,
                     GLContextEGL* shareContext,
                     bool isOffscreen,
                     EGLConfig config,
                     EGLSurface surface,
-                    nsACString& aFailureId);
+                    nsACString* const out_failureId);
 
 public:
     MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GLContextEGL, override)
     GLContextEGL(CreateContextFlags flags,
                  const SurfaceCaps& caps,
                  GLContext* shareContext,
                  bool isOffscreen,
                  EGLConfig config,
@@ -104,17 +104,17 @@ public:
     bool BindTex2DOffscreen(GLContext* aOffscreen);
     void UnbindTex2DOffscreen(GLContext* aOffscreen);
     void BindOffscreenFramebuffer();
 
     static already_AddRefed<GLContextEGL>
     CreateEGLPBufferOffscreenContext(CreateContextFlags flags,
                                      const gfx::IntSize& size,
                                      const SurfaceCaps& minCaps,
-                                     nsACString& aFailureId);
+                                     nsACString* const out_FailureId);
 
 protected:
     friend class GLContextProviderEGL;
 
 public:
     const EGLConfig  mConfig;
 protected:
     EGLSurface mSurface;
--- a/gfx/gl/GLContextProviderCGL.mm
+++ b/gfx/gl/GLContextProviderCGL.mm
@@ -317,47 +317,48 @@ CreateOffscreenFBOContext(CreateContextF
 
     if (gfxPrefs::GLMultithreaded()) {
         CGLEnable(glContext->GetCGLContext(), kCGLCEMPEngine);
     }
     return glContext.forget();
 }
 
 already_AddRefed<GLContext>
-GLContextProviderCGL::CreateHeadless(CreateContextFlags flags, nsACString& aFailureId)
+GLContextProviderCGL::CreateHeadless(CreateContextFlags flags,
+                                     nsACString* const out_failureId)
 {
     RefPtr<GLContextCGL> gl;
     gl = CreateOffscreenFBOContext(flags);
     if (!gl) {
-        aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_CGL_FBO");
+        *out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_CGL_FBO");
         return nullptr;
     }
 
     if (!gl->Init()) {
-        aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_CGL_INIT");
+        *out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_CGL_INIT");
         NS_WARNING("Failed during Init.");
         return nullptr;
     }
 
     return gl.forget();
 }
 
 already_AddRefed<GLContext>
 GLContextProviderCGL::CreateOffscreen(const IntSize& size,
                                       const SurfaceCaps& minCaps,
                                       CreateContextFlags flags,
-                                      nsACString& aFailureId)
+                                      nsACString* const out_failureId)
 {
-    RefPtr<GLContext> gl = CreateHeadless(flags, aFailureId);
+    RefPtr<GLContext> gl = CreateHeadless(flags, out_failureId);
     if (!gl) {
         return nullptr;
     }
 
     if (!gl->InitOffscreen(size, minCaps)) {
-        aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_CGL_INIT");
+        *out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_CGL_INIT");
         return nullptr;
     }
 
     return gl.forget();
 }
 
 static RefPtr<GLContext> gGlobalContext;
 
--- a/gfx/gl/GLContextProviderEGL.cpp
+++ b/gfx/gl/GLContextProviderEGL.cpp
@@ -451,17 +451,17 @@ void
 GLContextEGL::HoldSurface(gfxASurface* aSurf) {
     mThebesSurface = aSurf;
 }
 
 /* static */ EGLSurface
 GLContextEGL::CreateSurfaceForWindow(nsIWidget* aWidget)
 {
     nsCString discardFailureId;
-    if (!sEGLLibrary.EnsureInitialized(false, discardFailureId)) {
+    if (!sEGLLibrary.EnsureInitialized(false, &discardFailureId)) {
         MOZ_CRASH("GFX: Failed to load EGL library!\n");
         return nullptr;
     }
 
     EGLConfig config;
     if (!CreateConfig(&config, aWidget)) {
         MOZ_CRASH("GFX: Failed to create EGLConfig!\n");
         return nullptr;
@@ -485,20 +485,20 @@ GLContextEGL::DestroySurface(EGLSurface 
 
 already_AddRefed<GLContextEGL>
 GLContextEGL::CreateGLContext(CreateContextFlags flags,
                 const SurfaceCaps& caps,
                 GLContextEGL* shareContext,
                 bool isOffscreen,
                 EGLConfig config,
                 EGLSurface surface,
-                nsACString& aFailureId)
+                nsACString* const out_failureId)
 {
     if (sEGLLibrary.fBindAPI(LOCAL_EGL_OPENGL_ES_API) == LOCAL_EGL_FALSE) {
-        aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_ES");
+        *out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_ES");
         NS_WARNING("Failed to bind API to GLES!");
         return nullptr;
     }
 
     EGLContext eglShareContext = shareContext ? shareContext->mContext
                                               : EGL_NO_CONTEXT;
 
     nsTArray<EGLint> contextAttribs;
@@ -523,27 +523,27 @@ GLContextEGL::CreateGLContext(CreateCont
                                                     eglShareContext,
                                                     contextAttribs.Elements());
     if (!context && shareContext) {
         shareContext = nullptr;
         context = sEGLLibrary.fCreateContext(EGL_DISPLAY(), config, EGL_NO_CONTEXT,
                                              contextAttribs.Elements());
     }
     if (!context) {
-        aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_CREATE");
+        *out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_CREATE");
         NS_WARNING("Failed to create EGLContext!");
         return nullptr;
     }
 
     RefPtr<GLContextEGL> glContext = new GLContextEGL(flags, caps, shareContext,
                                                       isOffscreen, config, surface,
                                                       context);
 
     if (!glContext->Init()) {
-        aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_INIT");
+        *out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_INIT");
         return nullptr;
     }
 
     return glContext.forget();
 }
 
 EGLSurface
 GLContextEGL::CreatePBufferSurfaceTryingPowerOfTwo(EGLConfig config,
@@ -735,17 +735,17 @@ CreateConfig(EGLConfig* aConfig, nsIWidg
         return true;
     }
 }
 
 already_AddRefed<GLContext>
 GLContextProviderEGL::CreateWrappingExisting(void* aContext, void* aSurface)
 {
     nsCString discardFailureId;
-    if (!sEGLLibrary.EnsureInitialized(false, discardFailureId)) {
+    if (!sEGLLibrary.EnsureInitialized(false, &discardFailureId)) {
         MOZ_CRASH("GFX: Failed to load EGL library 2!\n");
         return nullptr;
     }
 
     if (!aContext || !aSurface)
         return nullptr;
 
     SurfaceCaps caps = SurfaceCaps::Any();
@@ -758,17 +758,17 @@ GLContextProviderEGL::CreateWrappingExis
 
     return gl.forget();
 }
 
 already_AddRefed<GLContext>
 GLContextProviderEGL::CreateForWindow(nsIWidget* aWidget, bool aForceAccelerated)
 {
     nsCString discardFailureId;
-    if (!sEGLLibrary.EnsureInitialized(false, discardFailureId)) {
+    if (!sEGLLibrary.EnsureInitialized(false, &discardFailureId)) {
         MOZ_CRASH("GFX: Failed to load EGL library 3!\n");
         return nullptr;
     }
 
     bool doubleBuffered = true;
 
     EGLConfig config;
     if (!CreateConfig(&config, aWidget)) {
@@ -780,17 +780,17 @@ GLContextProviderEGL::CreateForWindow(ns
     if (!surface) {
         MOZ_CRASH("GFX: Failed to create EGLSurface!\n");
         return nullptr;
     }
 
     SurfaceCaps caps = SurfaceCaps::Any();
     RefPtr<GLContextEGL> gl = GLContextEGL::CreateGLContext(CreateContextFlags::NONE,
                                                             caps, nullptr, false, config,
-                                                            surface, discardFailureId);
+                                                            surface, &discardFailureId);
     if (!gl) {
         MOZ_CRASH("GFX: Failed to create EGLContext!\n");
         mozilla::gl::DestroySurface(surface);
         return nullptr;
     }
 
     gl->MakeCurrent();
     gl->SetIsDoubleBuffered(doubleBuffered);
@@ -822,17 +822,17 @@ GLContextProviderEGL::CreateEGLSurface(v
 
     return surface;
 }
 
 void
 GLContextProviderEGL::DestroyEGLSurface(EGLSurface surface)
 {
     nsCString discardFailureId;
-    if (!sEGLLibrary.EnsureInitialized(false, discardFailureId)) {
+    if (!sEGLLibrary.EnsureInitialized(false, &discardFailureId)) {
         MOZ_CRASH("GFX: Failed to load EGL library 5!\n");
     }
 
     sEGLLibrary.fDestroySurface(EGL_DISPLAY(), surface);
 }
 #endif // defined(ANDROID)
 
 static void
@@ -934,122 +934,123 @@ ChooseConfig(GLLibraryEGL* egl, CreateCo
 
     return config;
 }
 
 /*static*/ already_AddRefed<GLContextEGL>
 GLContextEGL::CreateEGLPBufferOffscreenContext(CreateContextFlags flags,
                                                const mozilla::gfx::IntSize& size,
                                                const SurfaceCaps& minCaps,
-                                               nsACString& aFailureId)
+                                               nsACString* const out_failureId)
 {
     bool forceEnableHardware = bool(flags & CreateContextFlags::FORCE_ENABLE_HARDWARE);
-    if (!sEGLLibrary.EnsureInitialized(forceEnableHardware, aFailureId)) {
+    if (!sEGLLibrary.EnsureInitialized(forceEnableHardware, out_failureId)) {
         return nullptr;
     }
 
     SurfaceCaps configCaps;
     EGLConfig config = ChooseConfig(&sEGLLibrary, flags, minCaps, &configCaps);
     if (config == EGL_NO_CONFIG) {
-        aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_NO_CONFIG");
+        *out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_NO_CONFIG");
         NS_WARNING("Failed to find a compatible config.");
         return nullptr;
     }
 
     if (GLContext::ShouldSpew()) {
         sEGLLibrary.DumpEGLConfig(config);
     }
 
     mozilla::gfx::IntSize pbSize(size);
     EGLSurface surface = GLContextEGL::CreatePBufferSurfaceTryingPowerOfTwo(config,
                                                                             LOCAL_EGL_NONE,
                                                                             pbSize);
     if (!surface) {
-        aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_POT");
+        *out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_POT");
         NS_WARNING("Failed to create PBuffer for context!");
         return nullptr;
     }
 
     RefPtr<GLContextEGL> gl = GLContextEGL::CreateGLContext(flags, configCaps, nullptr,
                                                             true, config, surface,
-                                                            aFailureId);
+                                                            out_failureId);
     if (!gl) {
         NS_WARNING("Failed to create GLContext from PBuffer");
         sEGLLibrary.fDestroySurface(sEGLLibrary.Display(), surface);
         return nullptr;
     }
 
     return gl.forget();
 }
 
 /*static*/ already_AddRefed<GLContext>
-GLContextProviderEGL::CreateHeadless(CreateContextFlags flags, nsACString& aFailureId)
+GLContextProviderEGL::CreateHeadless(CreateContextFlags flags,
+                                     nsACString* const out_failureId)
 {
     mozilla::gfx::IntSize dummySize = mozilla::gfx::IntSize(16, 16);
     SurfaceCaps dummyCaps = SurfaceCaps::Any();
     return GLContextEGL::CreateEGLPBufferOffscreenContext(flags, dummySize, dummyCaps,
-                                                          aFailureId);
+                                                          out_failureId);
 }
 
 // Under EGL, on Android, pbuffers are supported fine, though
 // often without the ability to texture from them directly.
 /*static*/ already_AddRefed<GLContext>
 GLContextProviderEGL::CreateOffscreen(const mozilla::gfx::IntSize& size,
                                       const SurfaceCaps& minCaps,
                                       CreateContextFlags flags,
-                                      nsACString& aFailureId)
+                                      nsACString* const out_failureId)
 {
     bool forceEnableHardware = bool(flags & CreateContextFlags::FORCE_ENABLE_HARDWARE);
-    if (!sEGLLibrary.EnsureInitialized(forceEnableHardware, aFailureId)) { // Needed for IsANGLE().
-        aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_LIB_INIT");
+    if (!sEGLLibrary.EnsureInitialized(forceEnableHardware, out_failureId)) { // Needed for IsANGLE().
+        *out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_LIB_INIT");
         return nullptr;
     }
 
     bool canOffscreenUseHeadless = true;
     if (sEGLLibrary.IsANGLE()) {
         // ANGLE needs to use PBuffers.
         canOffscreenUseHeadless = false;
     }
 
     RefPtr<GLContext> gl;
     SurfaceCaps minOffscreenCaps = minCaps;
 
     if (canOffscreenUseHeadless) {
-        gl = CreateHeadless(flags, aFailureId);
+        gl = CreateHeadless(flags, out_failureId);
         if (!gl) {
             return nullptr;
         }
     } else {
         SurfaceCaps minBackbufferCaps = minOffscreenCaps;
         if (minOffscreenCaps.antialias) {
             minBackbufferCaps.antialias = false;
             minBackbufferCaps.depth = false;
             minBackbufferCaps.stencil = false;
         }
 
         gl = GLContextEGL::CreateEGLPBufferOffscreenContext(flags, size,
                                                             minBackbufferCaps,
-                                                            aFailureId);
+                                                            out_failureId);
         if (!gl)
             return nullptr;
 
         // Pull the actual resulting caps to ensure that our offscreen matches our
         // backbuffer.
         minOffscreenCaps.alpha = gl->Caps().alpha;
         if (!minOffscreenCaps.antialias) {
             // Only update these if we don't have AA. If we do have AA, we ignore
             // backbuffer depth/stencil.
             minOffscreenCaps.depth = gl->Caps().depth;
             minOffscreenCaps.stencil = gl->Caps().stencil;
         }
     }
 
     // Init the offscreen with the updated offscreen caps.
     if (!gl->InitOffscreen(size, minOffscreenCaps)) {
-        aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_OFFSCREEN");
+        *out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_OFFSCREEN");
         return nullptr;
     }
 
     return gl.forget();
 }
 
 // Don't want a global context on Android as 1) share groups across 2 threads fail on many Tegra drivers (bug 759225)
 // and 2) some mobile devices have a very strict limit on global number of GL contexts (bug 754257)
--- a/gfx/gl/GLContextProviderGLX.cpp
+++ b/gfx/gl/GLContextProviderGLX.cpp
@@ -1242,17 +1242,17 @@ GLContextGLX::FindFBConfigForWindow(Disp
     }
 
     NS_WARNING("[GLX] Couldn't find a FBConfig matching window visual");
     return false;
 }
 
 static already_AddRefed<GLContextGLX>
 CreateOffscreenPixmapContext(CreateContextFlags flags, const IntSize& size,
-                             const SurfaceCaps& minCaps, nsACString& aFailureId,
+                             const SurfaceCaps& minCaps, nsACString* const out_failureId,
                              ContextProfile profile = ContextProfile::OpenGLCompatibility)
 {
     GLXLibrary* glx = &sGLXLibrary;
     if (!glx->EnsureInitialized())
         return nullptr;
 
     Display* display = DefaultXDisplay();
     int screen = DefaultScreen(display);
@@ -1305,49 +1305,50 @@ DONE_CREATING_PIXMAP:
         return nullptr;
 
     GLContextGLX* shareContext = GetGlobalContextGLX();
     return GLContextGLX::CreateGLContext(flags, minCaps, shareContext, true, display,
                                          pixmap, config, true, surface, profile);
 }
 
 /*static*/ already_AddRefed<GLContext>
-GLContextProviderGLX::CreateHeadless(CreateContextFlags flags, nsACString& aFailureId)
+GLContextProviderGLX::CreateHeadless(CreateContextFlags flags,
+                                     nsACString* const out_failureId)
 {
     IntSize dummySize = IntSize(16, 16);
     SurfaceCaps dummyCaps = SurfaceCaps::Any();
-    return CreateOffscreenPixmapContext(flags, dummySize, dummyCaps, aFailureId);
+    return CreateOffscreenPixmapContext(flags, dummySize, dummyCaps, out_failureId);
 }
 
 /*static*/ already_AddRefed<GLContext>
 GLContextProviderGLX::CreateOffscreen(const IntSize& size,
                                       const SurfaceCaps& minCaps,
                                       CreateContextFlags flags,
-                                      nsACString& aFailureId)
+                                      nsACString* const out_failureId)
 {
     SurfaceCaps minBackbufferCaps = minCaps;
     if (minCaps.antialias) {
         minBackbufferCaps.antialias = false;
         minBackbufferCaps.depth = false;
         minBackbufferCaps.stencil = false;
     }
 
     ContextProfile profile = ContextProfile::OpenGLCore;
     if (flags & CreateContextFlags::REQUIRE_COMPAT_PROFILE) {
         profile = ContextProfile::OpenGLCompatibility;
     }
 
     RefPtr<GLContext> gl;
-    gl = CreateOffscreenPixmapContext(flags, size, minBackbufferCaps, aFailureId,
+    gl = CreateOffscreenPixmapContext(flags, size, minBackbufferCaps, out_failureId,
                                       profile);
     if (!gl)
         return nullptr;
 
     if (!gl->InitOffscreen(size, minCaps)) {
-        aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_GLX_INIT");
+        *out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_GLX_INIT");
         return nullptr;
     }
 
     return gl.forget();
 }
 
 /*static*/ GLContext*
 GLContextProviderGLX::GetGlobalContext()
--- a/gfx/gl/GLContextProviderImpl.h
+++ b/gfx/gl/GLContextProviderImpl.h
@@ -63,21 +63,21 @@ public:
      *                offscreen context.
      *
      * @return Context to use for offscreen rendering
      */
     static already_AddRefed<GLContext>
     CreateOffscreen(const mozilla::gfx::IntSize& size,
                     const SurfaceCaps& minCaps,
                     CreateContextFlags flags,
-                    nsACString& failureId);
+                    nsACString* const out_failureId);
 
     // Just create a context. We'll add offscreen stuff ourselves.
     static already_AddRefed<GLContext>
-    CreateHeadless(CreateContextFlags flags, nsACString& aFailureId);
+    CreateHeadless(CreateContextFlags flags, nsACString* const out_failureId);
 
     /**
      * Create wrapping Gecko GLContext for external gl context.
      *
      * @param aContext External context which will be wrapped by Gecko GLContext.
      * @param aSurface External surface which is used for external context.
      *
      * @return Wrapping Context to use for rendering
--- a/gfx/gl/GLContextProviderNull.cpp
+++ b/gfx/gl/GLContextProviderNull.cpp
@@ -19,19 +19,19 @@ GLContextProviderNull::CreateWrappingExi
 {
     return nullptr;
 }
 
 already_AddRefed<GLContext>
 GLContextProviderNull::CreateOffscreen(const gfx::IntSize&,
                                        const SurfaceCaps&,
                                        CreateContextFlags,
-                                       nsACString& aFailureId)
+                                       nsACString* const out_failureId)
 {
-    aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_NULL");
+    *out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_NULL");
     return nullptr;
 }
 
 already_AddRefed<GLContext>
 GLContextProviderNull::CreateHeadless(CreateContextFlags)
 {
     return nullptr;
 }
--- a/gfx/gl/GLContextProviderWGL.cpp
+++ b/gfx/gl/GLContextProviderWGL.cpp
@@ -628,17 +628,18 @@ CreateWindowOffscreenContext()
     RefPtr<GLContextWGL> glContext = new GLContextWGL(CreateContextFlags::NONE, caps,
                                                       shareContext, true, dc, context,
                                                       win);
 
     return glContext.forget();
 }
 
 /*static*/ already_AddRefed<GLContext>
-GLContextProviderWGL::CreateHeadless(CreateContextFlags flags, nsACString& aFailureId)
+GLContextProviderWGL::CreateHeadless(CreateContextFlags flags,
+                                     nsACString* const out_failureId)
 {
     if (!sWGLLib.EnsureInitialized()) {
         return nullptr;
     }
 
     RefPtr<GLContextWGL> glContext;
 
     // Always try to create a pbuffer context first, because we
@@ -665,24 +666,24 @@ GLContextProviderWGL::CreateHeadless(Cre
     RefPtr<GLContext> retGL = glContext.get();
     return retGL.forget();
 }
 
 /*static*/ already_AddRefed<GLContext>
 GLContextProviderWGL::CreateOffscreen(const IntSize& size,
                                       const SurfaceCaps& minCaps,
                                       CreateContextFlags flags,
-                                      nsACString& aFailureId)
+                                      nsACString* const out_failureId)
 {
-    RefPtr<GLContext> gl = CreateHeadless(flags, aFailureId);
+    RefPtr<GLContext> gl = CreateHeadless(flags, out_failureId);
     if (!gl)
         return nullptr;
 
     if (!gl->InitOffscreen(size, minCaps)) {
-        aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_WGL_INIT");
+        *out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_WGL_INIT");
         return nullptr;
     }
 
     return gl.forget();
 }
 
 static StaticRefPtr<GLContext> gGlobalContext;
 
@@ -690,17 +691,18 @@ static StaticRefPtr<GLContext> gGlobalCo
 GLContextProviderWGL::GetGlobalContext()
 {
     static bool triedToCreateContext = false;
     if (!triedToCreateContext) {
         triedToCreateContext = true;
 
         MOZ_RELEASE_ASSERT(!gGlobalContext, "GFX: Global GL context already initialized.");
         nsCString discardFailureId;
-        RefPtr<GLContext> temp = CreateHeadless(CreateContextFlags::NONE, discardFailureId);
+        RefPtr<GLContext> temp = CreateHeadless(CreateContextFlags::NONE,
+                                                &discardFailureId);
         gGlobalContext = temp;
     }
 
     return static_cast<GLContext*>(gGlobalContext);
 }
 
 /*static*/ void
 GLContextProviderWGL::Shutdown()
--- a/gfx/gl/GLLibraryEGL.cpp
+++ b/gfx/gl/GLLibraryEGL.cpp
@@ -137,28 +137,29 @@ GetAndInitWARPDisplay(GLLibraryEGL& egl,
 
     if (!egl.fInitialize(display, nullptr, nullptr))
         return EGL_NO_DISPLAY;
 
     return display;
 }
 
 static bool
-IsAccelAngleSupported(const nsCOMPtr<nsIGfxInfo>& gfxInfo, nsACString& aFailureId)
+IsAccelAngleSupported(const nsCOMPtr<nsIGfxInfo>& gfxInfo,
+                      nsACString* const out_failureId)
 {
     int32_t angleSupport;
     nsCString failureId;
     gfxUtils::ThreadSafeGetFeatureStatus(gfxInfo,
                                          nsIGfxInfo::FEATURE_WEBGL_ANGLE,
                                          failureId,
                                          &angleSupport);
     Telemetry::Accumulate(Telemetry::CANVAS_WEBGL_ACCL_FAILURE_ID,
                           failureId);
     if (failureId.IsEmpty()) {
-      aFailureId = failureId;
+        *out_failureId = failureId;
     }
     return (angleSupport == nsIGfxInfo::FEATURE_STATUS_OK);
 }
 
 static EGLDisplay
 GetAndInitDisplay(GLLibraryEGL& egl, void* displayType)
 {
     EGLDisplay display = egl.fGetDisplay(displayType);
@@ -201,17 +202,17 @@ GetAndInitDisplayForAccelANGLE(GLLibrary
 
 bool
 GLLibraryEGL::ReadbackEGLImage(EGLImage image, gfx::DataSourceSurface* out_surface)
 {
     StaticMutexAutoUnlock lock(sMutex);
     if (!mReadbackGL) {
         nsCString discardFailureId;
         mReadbackGL = gl::GLContextProvider::CreateHeadless(gl::CreateContextFlags::NONE,
-                                                            discardFailureId);
+                                                            &discardFailureId);
     }
 
     ScopedTexture destTex(mReadbackGL);
     const GLuint target = LOCAL_GL_TEXTURE_EXTERNAL;
     ScopedBindTexture autoTex(mReadbackGL, destTex.Texture(), target);
     mReadbackGL->fTexParameteri(target, LOCAL_GL_TEXTURE_WRAP_S, LOCAL_GL_CLAMP_TO_EDGE);
     mReadbackGL->fTexParameteri(target, LOCAL_GL_TEXTURE_WRAP_T, LOCAL_GL_CLAMP_TO_EDGE);
     mReadbackGL->fTexParameteri(target, LOCAL_GL_TEXTURE_MAG_FILTER, LOCAL_GL_NEAREST);
@@ -223,17 +224,17 @@ GLLibraryEGL::ReadbackEGLImage(EGLImage 
     int shaderConfig = config.mFeatures;
     mReadbackGL->ReadTexImageHelper()->ReadTexImage(out_surface, 0, target,
                                                     out_surface->GetSize(), shaderConfig);
 
     return true;
 }
 
 bool
-GLLibraryEGL::EnsureInitialized(bool forceAccel, nsACString& aFailureId)
+GLLibraryEGL::EnsureInitialized(bool forceAccel, nsACString* const out_failureId)
 {
     if (mInitialized) {
         return true;
     }
 
     mozilla::ScopedGfxFeatureReporter reporter("EGL");
 
 #ifdef MOZ_B2G
@@ -389,17 +390,17 @@ GLLibraryEGL::EnsureInitialized(bool for
 
     // Check the ANGLE support the system has
     nsCOMPtr<nsIGfxInfo> gfxInfo = do_GetService("@mozilla.org/gfx/info;1");
     mIsANGLE = IsExtensionSupported(ANGLE_platform_angle);
 
     EGLDisplay chosenDisplay = nullptr;
 
     if (IsExtensionSupported(ANGLE_platform_angle_d3d)) {
-        bool accelAngleSupport = IsAccelAngleSupported(gfxInfo, aFailureId);
+        bool accelAngleSupport = IsAccelAngleSupported(gfxInfo, out_failureId);
 
         bool shouldTryAccel = forceAccel || accelAngleSupport;
         bool shouldTryWARP = !shouldTryAccel;
         if (gfxPrefs::WebGLANGLEForceWARP()) {
             shouldTryWARP = true;
             shouldTryAccel = false;
         }
 
@@ -410,33 +411,33 @@ GLLibraryEGL::EnsureInitialized(bool for
                 mIsWARP = true;
             }
         }
 
         if (!chosenDisplay) {
             // If falling back to WARP did not work and we don't want to try
             // using HW accelerated ANGLE, then fail.
             if (!shouldTryAccel) {
-                if (aFailureId.IsEmpty()) {
-                    aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_WARP_FALLBACK");
+                if (out_failureId->IsEmpty()) {
+                    *out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_WARP_FALLBACK");
                 }
                 NS_ERROR("Fallback WARP ANGLE context failed to initialize.");
                 return false;
             }
 
             // Hardware accelerated ANGLE path
             chosenDisplay = GetAndInitDisplayForAccelANGLE(*this);
         }
     } else {
         chosenDisplay = GetAndInitDisplay(*this, EGL_DEFAULT_DISPLAY);
     }
 
     if (!chosenDisplay) {
-        if (aFailureId.IsEmpty()) {
-            aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_NO_DISPLAY");
+        if (out_failureId->IsEmpty()) {
+            *out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_NO_DISPLAY");
         }
         NS_WARNING("Failed to initialize a display.");
         return false;
     }
     mEGLDisplay = chosenDisplay;
 
     InitDisplayExtensions();
 
--- a/gfx/gl/GLLibraryEGL.h
+++ b/gfx/gl/GLLibraryEGL.h
@@ -530,17 +530,17 @@ public:
     }
 
     bool HasRobustness() const {
         return IsExtensionSupported(EXT_create_context_robustness);
     }
 
     bool ReadbackEGLImage(EGLImage image, gfx::DataSourceSurface* out_surface);
 
-    bool EnsureInitialized(bool forceAccel, nsACString& aFailureId);
+    bool EnsureInitialized(bool forceAccel, nsACString* const out_failureId);
 
     void DumpEGLConfig(EGLConfig cfg);
     void DumpEGLConfigs();
 
     struct {
         typedef EGLDisplay (GLAPIENTRY * pfnGetDisplay)(void* display_id);
         pfnGetDisplay fGetDisplay;
         typedef EGLDisplay(GLAPIENTRY * pfnGetPlatformDisplayEXT)(EGLenum platform, void* native_display, const EGLint* attrib_list);
--- a/gfx/layers/GLImages.cpp
+++ b/gfx/layers/GLImages.cpp
@@ -48,17 +48,17 @@ EGLImageImage::~EGLImageImage()
 already_AddRefed<gfx::SourceSurface>
 GLImage::GetAsSourceSurface()
 {
   MOZ_ASSERT(NS_IsMainThread(), "Should be on the main thread");
 
   if (!sSnapshotContext) {
     nsCString discardFailureId;
     sSnapshotContext = GLContextProvider::CreateHeadless(CreateContextFlags::NONE,
-                                                         discardFailureId);
+                                                         &discardFailureId);
     if (!sSnapshotContext) {
       NS_WARNING("Failed to create snapshot GLContext");
       return nullptr;
     }
   }
 
   sSnapshotContext->MakeCurrent();
   ScopedTexture scopedTex(sSnapshotContext);
--- a/gfx/layers/opengl/CompositorOGL.cpp
+++ b/gfx/layers/opengl/CompositorOGL.cpp
@@ -129,17 +129,17 @@ CompositorOGL::CreateContext()
   if (!context && gfxEnv::LayersPreferOffscreen()) {
     SurfaceCaps caps = SurfaceCaps::ForRGB();
     caps.preserve = false;
     caps.bpp16 = gfxPlatform::GetPlatform()->GetOffscreenFormat() == SurfaceFormat::R5G6B5_UINT16;
 
     nsCString discardFailureId;
     context = GLContextProvider::CreateOffscreen(mSurfaceSize,
                                                  caps, CreateContextFlags::REQUIRE_COMPAT_PROFILE,
-                                                 discardFailureId);
+                                                 &discardFailureId);
   }
 
   if (!context) {
     context = gl::GLContextProvider::CreateForWindow(mWidget->RealWidget(),
                 gfxPlatform::GetPlatform()->RequiresAcceleratedGLContextForCompositorOGL());
   }
 
   if (!context) {
--- a/gfx/tests/gtest/TestCompositor.cpp
+++ b/gfx/tests/gtest/TestCompositor.cpp
@@ -47,17 +47,17 @@ public:
     if (aDataType == NS_NATIVE_OPENGL_CONTEXT) {
       mozilla::gl::SurfaceCaps caps = mozilla::gl::SurfaceCaps::ForRGB();
       caps.preserve = false;
       caps.bpp16 = false;
       nsCString discardFailureId;
       RefPtr<GLContext> context = GLContextProvider::CreateOffscreen(
         IntSize(gCompWidth, gCompHeight), caps,
         CreateContextFlags::REQUIRE_COMPAT_PROFILE,
-        discardFailureId);
+        &discardFailureId);
       return context.forget().take();
     }
     return nullptr;
   }
 
   NS_IMETHOD              Create(nsIWidget* aParent,
                                  nsNativeWidget aNativeParent,
                                  const LayoutDeviceIntRect& aRect,
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -1321,17 +1321,17 @@ gfxPlatform::GetSkiaGLGlue()
      *
      * FIXME: This should be stored in TLS or something, since there needs to be one for each thread using it. As it
      * stands, this only works on the main thread.
      */
     RefPtr<GLContext> glContext;
     nsCString discardFailureId;
     glContext = GLContextProvider::CreateHeadless(CreateContextFlags::REQUIRE_COMPAT_PROFILE |
                                                   CreateContextFlags::ALLOW_OFFLINE_RENDERER,
-                                                  discardFailureId);
+                                                  &discardFailureId);
     if (!glContext) {
       printf_stderr("Failed to create GLContext for SkiaGL!\n");
       return nullptr;
     }
     mSkiaGlue = new SkiaGLGlue(glContext);
     MOZ_ASSERT(mSkiaGlue->GetGrContext(), "No GrContext");
     InitializeSkiaCacheLimits();
   }