Bug 1449205 - Share OpenGL contexts between WebRender windows on macOS. r=sotaro
Differential Revision: https://phabricator.services.mozilla.com/D53121
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "GLContext.h"
|
||||
#include "GLContextProvider.h"
|
||||
#include "mozilla/StaticPrefs_gfx.h"
|
||||
#include "mozilla/webrender/RenderThread.h"
|
||||
#include "mozilla/widget/CompositorWidget.h"
|
||||
|
||||
namespace mozilla {
|
||||
@@ -17,9 +18,11 @@ namespace wr {
|
||||
/* static */
|
||||
UniquePtr<RenderCompositor> RenderCompositorOGL::Create(
|
||||
RefPtr<widget::CompositorWidget>&& aWidget) {
|
||||
RefPtr<gl::GLContext> gl;
|
||||
gl = gl::GLContextProvider::CreateForCompositorWidget(
|
||||
aWidget, /* aWebRender */ true, /* aForceAccelerated */ true);
|
||||
RefPtr<gl::GLContext> gl = RenderThread::Get()->SharedGL();
|
||||
if (!gl) {
|
||||
gl = gl::GLContextProvider::CreateForCompositorWidget(
|
||||
aWidget, /* aWebRender */ true, /* aForceAccelerated */ true);
|
||||
}
|
||||
if (!gl || !gl->MakeCurrent()) {
|
||||
gfxCriticalNote << "Failed GL context creation for WebRender: "
|
||||
<< gfx::hexa(gl.get());
|
||||
|
||||
@@ -952,6 +952,16 @@ static already_AddRefed<gl::GLContext> CreateGLContextEGL() {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
static already_AddRefed<gl::GLContext> CreateGLContextCGL() {
|
||||
nsCString failureUnused;
|
||||
return gl::GLContextProvider::CreateHeadless(
|
||||
gl::CreateContextFlags::ALLOW_OFFLINE_RENDERER |
|
||||
gl::CreateContextFlags::FORCE_ENABLE_HARDWARE,
|
||||
&failureUnused);
|
||||
}
|
||||
#endif
|
||||
|
||||
static already_AddRefed<gl::GLContext> CreateGLContext() {
|
||||
#ifdef XP_WIN
|
||||
if (gfx::gfxVars::UseWebRenderANGLE()) {
|
||||
@@ -966,8 +976,11 @@ static already_AddRefed<gl::GLContext> CreateGLContext() {
|
||||
return CreateGLContextEGL();
|
||||
}
|
||||
#endif
|
||||
// We currently only support a shared GLContext
|
||||
// with ANGLE.
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
return CreateGLContextCGL();
|
||||
#endif
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user