diff --git a/gfx/gl/GLContextProvider.h b/gfx/gl/GLContextProvider.h index 10b0ea73ad8b..2a5d7c328435 100644 --- a/gfx/gl/GLContextProvider.h +++ b/gfx/gl/GLContextProvider.h @@ -23,6 +23,8 @@ enum class CreateContextFlags : int8_t { REQUIRE_COMPAT_PROFILE = 1 << 0, // 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, }; MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(CreateContextFlags) diff --git a/gfx/gl/GLContextProviderCGL.mm b/gfx/gl/GLContextProviderCGL.mm index c39cd04aabf5..22b9f7ac3c18 100644 --- a/gfx/gl/GLContextProviderCGL.mm +++ b/gfx/gl/GLContextProviderCGL.mm @@ -187,6 +187,11 @@ static const NSOpenGLPixelFormatAttribute kAttribs_offscreen[] = { 0 }; +static const NSOpenGLPixelFormatAttribute kAttribs_offscreen_allow_offline[] = { + NSOpenGLPFAAllowOfflineRenderers, + 0 +}; + static const NSOpenGLPixelFormatAttribute kAttribs_offscreen_accel[] = { NSOpenGLPFAAccelerated, 0 @@ -269,10 +274,18 @@ CreateOffscreenFBOContext(CreateContextFlags flags) if (!context) { profile = ContextProfile::OpenGLCompatibility; - if (gfxPrefs::RequireHardwareGL()) - context = CreateWithFormat(kAttribs_offscreen_accel); - else - context = CreateWithFormat(kAttribs_offscreen); + if (flags & CreateContextFlags::ALLOW_OFFLINE_RENDERER) { + if (gfxPrefs::RequireHardwareGL()) + context = CreateWithFormat(kAttribs_singleBuffered); + else + context = CreateWithFormat(kAttribs_offscreen_allow_offline); + + } else { + if (gfxPrefs::RequireHardwareGL()) + context = CreateWithFormat(kAttribs_offscreen_accel); + else + context = CreateWithFormat(kAttribs_offscreen); + } } if (!context) { NS_WARNING("Failed to create NSOpenGLContext."); diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index a6e36bb97d74..3915757193fb 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -1090,7 +1090,8 @@ gfxPlatform::GetSkiaGLGlue() * stands, this only works on the main thread. */ nsRefPtr glContext; - glContext = GLContextProvider::CreateHeadless(CreateContextFlags::REQUIRE_COMPAT_PROFILE); + glContext = GLContextProvider::CreateHeadless(CreateContextFlags::REQUIRE_COMPAT_PROFILE | + CreateContextFlags::ALLOW_OFFLINE_RENDERER); if (!glContext) { printf_stderr("Failed to create GLContext for SkiaGL!\n"); return nullptr;