Bug 1278403 - Misc code cleanup. - r=jrmuizel
authorJeff Gilbert <jgilbert@mozilla.com>
Mon, 06 Jun 2016 17:31:53 -0700
changeset 302224 dfb9047aaa22d513ae6c8da42bf3f81466cffed8
parent 302223 a5383918f68fdb3d724652c82eef16b74191e84a
child 302225 43de2b8ce001325d475aadfcea4f5ca3c79bf274
push id78653
push userjgilbert@mozilla.com
push dateTue, 21 Jun 2016 20:47:33 +0000
treeherdermozilla-inbound@496586403d9d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1278403
milestone50.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 1278403 - Misc code cleanup. - r=jrmuizel MozReview-Commit-ID: 3ccHiLQM6lm
gfx/gl/GLContextProviderEGL.cpp
gfx/gl/GLContextProviderGLX.cpp
gfx/gl/GLContextProviderWGL.cpp
--- a/gfx/gl/GLContextProviderEGL.cpp
+++ b/gfx/gl/GLContextProviderEGL.cpp
@@ -188,24 +188,19 @@ CreateSurfaceForWindow(nsIWidget* widget
     AndroidBridge::Bridge()->ReleaseNativeWindow(nativeWindow);
 #else
     newSurface = sEGLLibrary.fCreateWindowSurface(EGL_DISPLAY(), config,
                                                   GET_NATIVE_WINDOW(widget), 0);
 #endif
     return newSurface;
 }
 
-GLContextEGL::GLContextEGL(
-                  CreateContextFlags flags,
-                  const SurfaceCaps& caps,
-                  GLContext* shareContext,
-                  bool isOffscreen,
-                  EGLConfig config,
-                  EGLSurface surface,
-                  EGLContext context)
+GLContextEGL::GLContextEGL(CreateContextFlags flags, const SurfaceCaps& caps,
+                           GLContext* shareContext, bool isOffscreen, EGLConfig config,
+                           EGLSurface surface, EGLContext context)
     : GLContext(flags, caps, shareContext, isOffscreen)
     , mConfig(config)
     , mSurface(surface)
     , mContext(context)
     , mSurfaceOverride(EGL_NO_SURFACE)
     , mThebesSurface(nullptr)
     , mBound(false)
     , mIsPBuffer(false)
@@ -524,33 +519,28 @@ GLContextEGL::CreateGLContext(CreateCont
     }
 
     EGLContext context = sEGLLibrary.fCreateContext(EGL_DISPLAY(),
                                                     config,
                                                     eglShareContext,
                                                     contextAttribs.Elements());
     if (!context && shareContext) {
         shareContext = nullptr;
-        context = sEGLLibrary.fCreateContext(EGL_DISPLAY(),
-                                              config,
-                                              EGL_NO_CONTEXT,
-                                              contextAttribs.Elements());
+        context = sEGLLibrary.fCreateContext(EGL_DISPLAY(), config, EGL_NO_CONTEXT,
+                                             contextAttribs.Elements());
     }
     if (!context) {
         aFailureId = 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);
+    RefPtr<GLContextEGL> glContext = new GLContextEGL(flags, caps, shareContext,
+                                                      isOffscreen, config, surface,
+                                                      context);
 
     if (!glContext->Init()) {
         aFailureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_INIT");
         return nullptr;
     }
 
     return glContext.forget();
 }
@@ -750,31 +740,28 @@ already_AddRefed<GLContext>
 GLContextProviderEGL::CreateWrappingExisting(void* aContext, void* aSurface)
 {
     nsCString discardFailureId;
     if (!sEGLLibrary.EnsureInitialized(false, discardFailureId)) {
         MOZ_CRASH("GFX: Failed to load EGL library 2!\n");
         return nullptr;
     }
 
-    if (aContext && aSurface) {
-        SurfaceCaps caps = SurfaceCaps::Any();
-        EGLConfig config = EGL_NO_CONFIG;
-        RefPtr<GLContextEGL> glContext =
-            new GLContextEGL(CreateContextFlags::NONE, caps,
-                             nullptr, false,
-                             config, (EGLSurface)aSurface, (EGLContext)aContext);
+    if (!aContext || !aSurface)
+        return nullptr;
 
-        glContext->SetIsDoubleBuffered(true);
-        glContext->mOwnsContext = false;
+    SurfaceCaps caps = SurfaceCaps::Any();
+    EGLConfig config = EGL_NO_CONFIG;
+    RefPtr<GLContextEGL> gl = new GLContextEGL(CreateContextFlags::NONE, caps, nullptr,
+                                               false, config, (EGLSurface)aSurface,
+                                               (EGLContext)aContext);
+    gl->SetIsDoubleBuffered(true);
+    gl->mOwnsContext = false;
 
-        return glContext.forget();
-    }
-
-    return nullptr;
+    return gl.forget();
 }
 
 already_AddRefed<GLContext>
 GLContextProviderEGL::CreateForWindow(nsIWidget *aWidget, bool aForceAccelerated)
 {
     nsCString discardFailureId;
     if (!sEGLLibrary.EnsureInitialized(false, discardFailureId)) {
         MOZ_CRASH("GFX: Failed to load EGL library 3!\n");
@@ -791,31 +778,29 @@ GLContextProviderEGL::CreateForWindow(ns
 
     EGLSurface surface = mozilla::gl::CreateSurfaceForWindow(aWidget, config);
     if (!surface) {
         MOZ_CRASH("GFX: Failed to create EGLSurface!\n");
         return nullptr;
     }
 
     SurfaceCaps caps = SurfaceCaps::Any();
-    RefPtr<GLContextEGL> glContext =
-        GLContextEGL::CreateGLContext(CreateContextFlags::NONE, caps,
-                                      nullptr, false,
-                                      config, surface, discardFailureId);
-
-    if (!glContext) {
+    RefPtr<GLContextEGL> gl = GLContextEGL::CreateGLContext(CreateContextFlags::NONE,
+                                                            caps, nullptr, false, config,
+                                                            surface, discardFailureId);
+    if (!gl) {
         MOZ_CRASH("GFX: Failed to create EGLContext!\n");
         mozilla::gl::DestroySurface(surface);
         return nullptr;
     }
 
-    glContext->MakeCurrent();
-    glContext->SetIsDoubleBuffered(doubleBuffered);
+    gl->MakeCurrent();
+    gl->SetIsDoubleBuffered(doubleBuffered);
 
-    return glContext.forget();
+    return gl.forget();
 }
 
 #if defined(ANDROID)
 EGLSurface
 GLContextProviderEGL::CreateEGLSurface(void* aWindow)
 {
     nsCString discardFailureId;
     if (!sEGLLibrary.EnsureInitialized(false, discardFailureId)) {
@@ -824,18 +809,18 @@ GLContextProviderEGL::CreateEGLSurface(v
 
     EGLConfig config;
     if (!CreateConfig(&config, static_cast<nsIWidget*>(aWindow))) {
         MOZ_CRASH("GFX: Failed to create EGLConfig 2!\n");
     }
 
     MOZ_ASSERT(aWindow);
 
-    EGLSurface surface = sEGLLibrary.fCreateWindowSurface(EGL_DISPLAY(), config, aWindow, 0);
-
+    EGLSurface surface = sEGLLibrary.fCreateWindowSurface(EGL_DISPLAY(), config, aWindow,
+                                                          0);
     if (surface == EGL_NO_SURFACE) {
         MOZ_CRASH("GFX: Failed to create EGLSurface 2!\n");
     }
 
     return surface;
 }
 
 void
@@ -978,18 +963,19 @@ GLContextEGL::CreateEGLPBufferOffscreenC
                                                                             LOCAL_EGL_NONE,
                                                                             pbSize);
     if (!surface) {
         aFailureId = 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);
+    RefPtr<GLContextEGL> gl = GLContextEGL::CreateGLContext(flags, configCaps, nullptr,
+                                                            true, config, surface,
+                                                            aFailureId);
     if (!gl) {
         NS_WARNING("Failed to create GLContext from PBuffer");
         sEGLLibrary.fDestroySurface(sEGLLibrary.Display(), surface);
         return nullptr;
     }
 
     return gl.forget();
 }
@@ -1034,21 +1020,21 @@ GLContextProviderEGL::CreateOffscreen(co
     } else {
         SurfaceCaps minBackbufferCaps = minOffscreenCaps;
         if (minOffscreenCaps.antialias) {
             minBackbufferCaps.antialias = false;
             minBackbufferCaps.depth = false;
             minBackbufferCaps.stencil = false;
         }
 
-        gl = GLContextEGL::CreateEGLPBufferOffscreenContext(flags, size, minBackbufferCaps,
+        gl = GLContextEGL::CreateEGLPBufferOffscreenContext(flags, size,
+                                                            minBackbufferCaps,
                                                             aFailureId);
-        if (!gl) {
+        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;
--- a/gfx/gl/GLContextProviderGLX.cpp
+++ b/gfx/gl/GLContextProviderGLX.cpp
@@ -774,26 +774,21 @@ GLXLibrary::xWaitVideoSync(int divisor, 
 {
     BEFORE_GLX_CALL;
     int result = xWaitVideoSyncInternal(divisor, remainder, count);
     AFTER_GLX_CALL;
     return result;
 }
 
 already_AddRefed<GLContextGLX>
-GLContextGLX::CreateGLContext(CreateContextFlags flags,
-                  const SurfaceCaps& caps,
-                  GLContextGLX* shareContext,
-                  bool isOffscreen,
-                  Display* display,
-                  GLXDrawable drawable,
-                  GLXFBConfig cfg,
-                  bool deleteDrawable,
-                  gfxXlibSurface* pixmap,
-                  ContextProfile profile)
+GLContextGLX::CreateGLContext(CreateContextFlags flags, const SurfaceCaps& caps,
+                              GLContextGLX* shareContext, bool isOffscreen,
+                              Display* display, GLXDrawable drawable, GLXFBConfig cfg,
+                              bool deleteDrawable, gfxXlibSurface* pixmap,
+                              ContextProfile profile)
 {
     GLXLibrary& glx = sGLXLibrary;
 
     int db = 0;
     int err = glx.xGetFBConfigAttrib(display, cfg,
                                       LOCAL_GLX_DOUBLEBUFFER, &db);
     if (LOCAL_GLX_BAD_ATTRIBUTE != err) {
         if (ShouldSpew()) {
@@ -842,26 +837,19 @@ TRY_AGAIN_NO_SHARING:
             display,
             cfg,
             LOCAL_GLX_RGBA_TYPE,
             glxContext,
             True);
     }
 
     if (context) {
-        glContext = new GLContextGLX(flags, caps,
-                                      shareContext,
-                                      isOffscreen,
-                                      display,
-                                      drawable,
-                                      context,
-                                      deleteDrawable,
-                                      db,
-                                      pixmap,
-                                      profile);
+        glContext = new GLContextGLX(flags, caps, shareContext, isOffscreen, display,
+                                     drawable, context, deleteDrawable, db, pixmap,
+                                     profile);
         if (!glContext->Init())
             error = true;
     } else {
         error = true;
     }
 
     error |= xErrorHandler.SyncAndGetError(display);
 
@@ -1115,29 +1103,23 @@ GLContextProviderGLX::CreateForWindow(ns
     GLXFBConfig config;
     int visid;
     if (!GLContextGLX::FindFBConfigForWindow(display, xscreen, window, &cfgs,
                                              &config, &visid))
     {
         return nullptr;
     }
 
-    GLContextGLX *shareContext = GetGlobalContextGLX();
-
     SurfaceCaps caps = SurfaceCaps::Any();
-    RefPtr<GLContextGLX> glContext = GLContextGLX::CreateGLContext(CreateContextFlags::NONE,
-                                                                   caps,
-                                                                   shareContext,
-                                                                   false,
-                                                                   display,
-                                                                   window,
-                                                                   config,
-                                                                   false);
-
-    return glContext.forget();
+    GLContextGLX* shareContext = GetGlobalContextGLX();
+    RefPtr<GLContextGLX> gl = GLContextGLX::CreateGLContext(CreateContextFlags::NONE,
+                                                            caps, shareContext, false,
+                                                            display, window, config,
+                                                            false);
+    return gl.forget();
 }
 
 static bool
 ChooseConfig(GLXLibrary* glx, Display* display, int screen, const SurfaceCaps& minCaps,
              ScopedXFree<GLXFBConfig>* const out_scopedConfigArr,
              GLXFBConfig* const out_config, int* const out_visid)
 {
     ScopedXFree<GLXFBConfig>& scopedConfigArr = *out_scopedConfigArr;
--- a/gfx/gl/GLContextProviderWGL.cpp
+++ b/gfx/gl/GLContextProviderWGL.cpp
@@ -261,43 +261,34 @@ WGLLibrary::EnsureInitialized()
         mInitialized = false;
         return false;
     }
 
     reporter.SetSuccessful();
     return true;
 }
 
-GLContextWGL::GLContextWGL(CreateContextFlags flags,
-                  const SurfaceCaps& caps,
-                  GLContext* sharedContext,
-                  bool isOffscreen,
-                  HDC aDC,
-                  HGLRC aContext,
-                  HWND aWindow)
+GLContextWGL::GLContextWGL(CreateContextFlags flags, const SurfaceCaps& caps,
+                           GLContext* sharedContext, bool isOffscreen, HDC aDC,
+                           HGLRC aContext, HWND aWindow)
     : GLContext(flags, caps, sharedContext, isOffscreen),
       mDC(aDC),
       mContext(aContext),
       mWnd(aWindow),
       mPBuffer(nullptr),
       mPixelFormat(0),
       mIsDoubleBuffered(false)
 {
     // See 899855
     SetProfileVersion(ContextProfile::OpenGLCompatibility, 200);
 }
 
-GLContextWGL::GLContextWGL(CreateContextFlags flags,
-                  const SurfaceCaps& caps,
-                  GLContext* sharedContext,
-                  bool isOffscreen,
-                  HANDLE aPbuffer,
-                  HDC aDC,
-                  HGLRC aContext,
-                  int aPixelFormat)
+GLContextWGL::GLContextWGL(CreateContextFlags flags, const SurfaceCaps& caps,
+                           GLContext* sharedContext, bool isOffscreen, HANDLE aPbuffer,
+                           HDC aDC, HGLRC aContext, int aPixelFormat)
     : GLContext(flags, caps, sharedContext, isOffscreen),
       mDC(aDC),
       mContext(aContext),
       mWnd(nullptr),
       mPBuffer(aPbuffer),
       mPixelFormat(aPixelFormat),
       mIsDoubleBuffered(false)
 {
@@ -630,18 +621,18 @@ CreateWindowOffscreenContext()
     }
 
     if (!context) {
         return nullptr;
     }
 
     SurfaceCaps caps = SurfaceCaps::ForRGBA();
     RefPtr<GLContextWGL> glContext = new GLContextWGL(CreateContextFlags::NONE, caps,
-                                                        shareContext, true,
-                                                        dc, context, win);
+                                                      shareContext, true, dc, context,
+                                                      win);
 
     return glContext.forget();
 }
 
 /*static*/ already_AddRefed<GLContext>
 GLContextProviderWGL::CreateHeadless(CreateContextFlags flags, nsACString& aFailureId)
 {
     if (!sWGLLib.EnsureInitialized()) {