Centralize EnsureInitialized. r?jrmuizel draft
authorJeff Gilbert <jdashg@gmail.com>
Tue, 12 Apr 2016 13:54:36 -0700
changeset 354500 3cd5b67d7916a1aadbd43f5f43f1c57c211f9306
parent 354499 6daa9936e04362bb174b762fc858ff13d2931b3d
child 354501 0860a44f78a9a03da39fb552fc650219de79f6ef
push id16095
push userjgilbert@mozilla.com
push dateThu, 21 Apr 2016 00:49:36 +0000
reviewersjrmuizel
milestone48.0a1
Centralize EnsureInitialized. r?jrmuizel From f4bd3eb31958e006b965c8e012a137b2d3c083f4 Mon Sep 17 00:00:00 2001 --- gfx/gl/GLContextProviderEGL.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) MozReview-Commit-ID: 4WNSoHdHSV4
gfx/gl/GLContextProviderEGL.cpp
--- a/gfx/gl/GLContextProviderEGL.cpp
+++ b/gfx/gl/GLContextProviderEGL.cpp
@@ -923,16 +923,20 @@ ChooseConfig(GLLibraryEGL* egl, CreateCo
     return config;
 }
 
 /*static*/ already_AddRefed<GLContextEGL>
 GLContextEGL::CreateEGLPBufferOffscreenContext(CreateContextFlags flags,
                                                const mozilla::gfx::IntSize& size,
                                                const SurfaceCaps& minCaps)
 {
+    bool forceEnableHardware = bool(flags & CreateContextFlags::FORCE_ENABLE_HARDWARE);
+    if (!sEGLLibrary.EnsureInitialized(forceEnableHardware))
+        return nullptr;
+
     SurfaceCaps configCaps;
     EGLConfig config = ChooseConfig(&sEGLLibrary, flags, minCaps, &configCaps);
     if (config == EGL_NO_CONFIG) {
         NS_WARNING("Failed to find a compatible config.");
         return nullptr;
     }
 
     if (GLContext::ShouldSpew())
@@ -963,36 +967,28 @@ GLContextEGL::CreateEGLPBufferOffscreenC
     }
 
     return gl.forget();
 }
 
 /*static*/ already_AddRefed<GLContext>
 GLContextProviderEGL::CreateHeadless(CreateContextFlags flags)
 {
-    bool forceEnableHardware = bool(flags & CreateContextFlags::FORCE_ENABLE_HARDWARE);
-    if (!sEGLLibrary.EnsureInitialized(forceEnableHardware))
-        return nullptr;
-
     mozilla::gfx::IntSize dummySize = mozilla::gfx::IntSize(16, 16);
     SurfaceCaps dummyCaps = SurfaceCaps::Any();
     return GLContextEGL::CreateEGLPBufferOffscreenContext(flags, dummySize, dummyCaps);
 }
 
 // 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)
 {
-    bool forceEnableHardware = bool(flags & CreateContextFlags::FORCE_ENABLE_HARDWARE);
-    if (!sEGLLibrary.EnsureInitialized(forceEnableHardware))
-        return nullptr;
-
     bool canOffscreenUseHeadless = true;
     if (sEGLLibrary.IsANGLE()) {
         // ANGLE needs to use PBuffers.
         canOffscreenUseHeadless = false;
     }
 
     RefPtr<GLContext> gl;
     SurfaceCaps minOffscreenCaps = minCaps;