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 "GLContext.h"
|
||||||
#include "GLContextProvider.h"
|
#include "GLContextProvider.h"
|
||||||
#include "mozilla/StaticPrefs_gfx.h"
|
#include "mozilla/StaticPrefs_gfx.h"
|
||||||
|
#include "mozilla/webrender/RenderThread.h"
|
||||||
#include "mozilla/widget/CompositorWidget.h"
|
#include "mozilla/widget/CompositorWidget.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
@@ -17,9 +18,11 @@ namespace wr {
|
|||||||
/* static */
|
/* static */
|
||||||
UniquePtr<RenderCompositor> RenderCompositorOGL::Create(
|
UniquePtr<RenderCompositor> RenderCompositorOGL::Create(
|
||||||
RefPtr<widget::CompositorWidget>&& aWidget) {
|
RefPtr<widget::CompositorWidget>&& aWidget) {
|
||||||
RefPtr<gl::GLContext> gl;
|
RefPtr<gl::GLContext> gl = RenderThread::Get()->SharedGL();
|
||||||
|
if (!gl) {
|
||||||
gl = gl::GLContextProvider::CreateForCompositorWidget(
|
gl = gl::GLContextProvider::CreateForCompositorWidget(
|
||||||
aWidget, /* aWebRender */ true, /* aForceAccelerated */ true);
|
aWidget, /* aWebRender */ true, /* aForceAccelerated */ true);
|
||||||
|
}
|
||||||
if (!gl || !gl->MakeCurrent()) {
|
if (!gl || !gl->MakeCurrent()) {
|
||||||
gfxCriticalNote << "Failed GL context creation for WebRender: "
|
gfxCriticalNote << "Failed GL context creation for WebRender: "
|
||||||
<< gfx::hexa(gl.get());
|
<< gfx::hexa(gl.get());
|
||||||
|
|||||||
@@ -952,6 +952,16 @@ static already_AddRefed<gl::GLContext> CreateGLContextEGL() {
|
|||||||
}
|
}
|
||||||
#endif
|
#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() {
|
static already_AddRefed<gl::GLContext> CreateGLContext() {
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
if (gfx::gfxVars::UseWebRenderANGLE()) {
|
if (gfx::gfxVars::UseWebRenderANGLE()) {
|
||||||
@@ -966,8 +976,11 @@ static already_AddRefed<gl::GLContext> CreateGLContext() {
|
|||||||
return CreateGLContextEGL();
|
return CreateGLContextEGL();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// We currently only support a shared GLContext
|
|
||||||
// with ANGLE.
|
#ifdef XP_MACOSX
|
||||||
|
return CreateGLContextCGL();
|
||||||
|
#endif
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user