Bug 1339256 - Only request robustness if requested on EGL - r=daoshengmu draft
authorJeff Gilbert <jgilbert@mozilla.com>
Thu, 09 Mar 2017 12:30:01 -0800
changeset 496212 3b5877718f5b8e623bc166e1fe26f43771be1881
parent 496211 bf521165d8c04c856c8218998ce52220e257bff4
child 496213 f343a81a732f7cf04e0a3ea0416bd696b7cf384b
push id48558
push userbmo:jgilbert@mozilla.com
push dateFri, 10 Mar 2017 00:02:25 +0000
reviewersdaoshengmu
bugs1339256
milestone55.0a1
Bug 1339256 - Only request robustness if requested on EGL - r=daoshengmu MozReview-Commit-ID: GlMpalFwS2U
dom/canvas/WebGLContext.cpp
gfx/gl/GLContextProviderEGL.cpp
gfx/gl/GLContextTypes.h
--- a/dom/canvas/WebGLContext.cpp
+++ b/dom/canvas/WebGLContext.cpp
@@ -722,17 +722,18 @@ WebGLContext::CreateAndInitGL(bool force
             reason.info.Append(reason.key);
             out_failReasons->push_back(reason);
             GenerateWarning("%s", reason.info.BeginReading());
             return false;
         }
     }
 
     const gl::SurfaceCaps baseCaps = BaseCaps(mOptions, this);
-    gl::CreateContextFlags flags = gl::CreateContextFlags::NO_VALIDATION;
+    gl::CreateContextFlags flags = (gl::CreateContextFlags::NO_VALIDATION |
+                                    gl::CreateContextFlags::PREFER_ROBUSTNESS);
     bool tryNativeGL = true;
     bool tryANGLE = false;
 
     if (forceEnabled) {
         flags |= gl::CreateContextFlags::FORCE_ENABLE_HARDWARE;
     }
 
     if (IsWebGL2()) {
--- a/gfx/gl/GLContextProviderEGL.cpp
+++ b/gfx/gl/GLContextProviderEGL.cpp
@@ -485,26 +485,28 @@ GLContextEGL::CreateGLContext(CreateCont
     std::vector<EGLint> contextAttribs;
 
     contextAttribs.push_back(LOCAL_EGL_CONTEXT_CLIENT_VERSION);
     if (flags & CreateContextFlags::PREFER_ES3)
         contextAttribs.push_back(3);
     else
         contextAttribs.push_back(2);
 
-    if (sEGLLibrary.IsExtensionSupported(GLLibraryEGL::KHR_create_context)) {
-        contextAttribs.push_back(LOCAL_EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR);
-        contextAttribs.push_back(LOCAL_EGL_LOSE_CONTEXT_ON_RESET_KHR);
-        contextAttribs.push_back(LOCAL_EGL_CONTEXT_FLAGS_KHR);
-        contextAttribs.push_back(LOCAL_EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR);
-    } else if (sEGLLibrary.IsExtensionSupported(GLLibraryEGL::EXT_create_context_robustness)) {
-        contextAttribs.push_back(LOCAL_EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT);
-        contextAttribs.push_back(LOCAL_EGL_LOSE_CONTEXT_ON_RESET_EXT);
-        contextAttribs.push_back(LOCAL_EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT);
-        contextAttribs.push_back(LOCAL_EGL_TRUE);
+    if (flags & CreateContextFlags::PREFER_ROBUSTNESS) {
+        if (sEGLLibrary.IsExtensionSupported(GLLibraryEGL::KHR_create_context)) {
+            contextAttribs.push_back(LOCAL_EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR);
+            contextAttribs.push_back(LOCAL_EGL_LOSE_CONTEXT_ON_RESET_KHR);
+            contextAttribs.push_back(LOCAL_EGL_CONTEXT_FLAGS_KHR);
+            contextAttribs.push_back(LOCAL_EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR);
+        } else if (sEGLLibrary.IsExtensionSupported(GLLibraryEGL::EXT_create_context_robustness)) {
+            contextAttribs.push_back(LOCAL_EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT);
+            contextAttribs.push_back(LOCAL_EGL_LOSE_CONTEXT_ON_RESET_EXT);
+            contextAttribs.push_back(LOCAL_EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT);
+            contextAttribs.push_back(LOCAL_EGL_TRUE);
+        }
     }
 
     for (const auto& cur : kTerminationAttribs) {
         contextAttribs.push_back(cur);
     }
 
     EGLContext context = sEGLLibrary.fCreateContext(EGL_DISPLAY(),
                                                     config,
--- a/gfx/gl/GLContextTypes.h
+++ b/gfx/gl/GLContextTypes.h
@@ -51,15 +51,16 @@ enum class CreateContextFlags : int8_t {
     // Force the use of hardware backed GL, don't allow software implementations.
     FORCE_ENABLE_HARDWARE = 1 << 1,
     /* Don't force discrete GPU to be used (if applicable) */
     ALLOW_OFFLINE_RENDERER =  1 << 2,
     // Ask for ES3 if possible
     PREFER_ES3 = 1 << 3,
 
     NO_VALIDATION = 1 << 4,
+    PREFER_ROBUSTNESS = 1 << 5,
 };
 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(CreateContextFlags)
 
 } /* namespace gl */
 } /* namespace mozilla */
 
 #endif /* GLCONTEXT_TYPES_H_ */