Bug 1699001 - Rename RenderThread::SharedGL() to SingletonGL() r=nical
Name of Singleton is commonly used in gecko. Name of SharedGL is confusing. It looks like "shared context", but it is not. The GL context is actually a singleton GLContext that is used by all WebRender. Each window creates one EGLSurface for each window. EGLSurface is switched for each window rendering. Differential Revision: https://phabricator.services.mozilla.com/D108714
This commit is contained in:
@@ -47,7 +47,7 @@ wr::WrExternalImage RenderAndroidSurfaceTextureHost::Lock(
|
||||
mPrepareStatus == STATUS_UPDATE_TEX_IMAGE_NEEDED));
|
||||
|
||||
if (mGL.get() != aGL) {
|
||||
// This should not happen. On android, SharedGL is used.
|
||||
// This should not happen. On android, SingletonGL is used.
|
||||
MOZ_ASSERT_UNREACHABLE("Unexpected GL context");
|
||||
return InvalidToWrExternalImage();
|
||||
}
|
||||
@@ -99,7 +99,7 @@ bool RenderAndroidSurfaceTextureHost::EnsureAttachedToGLContext() {
|
||||
}
|
||||
|
||||
if (!mGL) {
|
||||
mGL = RenderThread::Get()->SharedGL();
|
||||
mGL = RenderThread::Get()->SingletonGL();
|
||||
}
|
||||
|
||||
if (!mSurfTex || !mGL || !mGL->MakeCurrent()) {
|
||||
@@ -210,7 +210,7 @@ gfx::SurfaceFormat RenderAndroidSurfaceTextureHost::GetFormat() const {
|
||||
already_AddRefed<DataSourceSurface>
|
||||
RenderAndroidSurfaceTextureHost::ReadTexImage() {
|
||||
if (!mGL) {
|
||||
mGL = RenderThread::Get()->SharedGL();
|
||||
mGL = RenderThread::Get()->SingletonGL();
|
||||
if (!mGL) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace wr {
|
||||
/* static */
|
||||
UniquePtr<RenderCompositor> RenderCompositorANGLE::Create(
|
||||
RefPtr<widget::CompositorWidget>&& aWidget, nsACString& aError) {
|
||||
const auto& gl = RenderThread::Get()->SharedGL(aError);
|
||||
const auto& gl = RenderThread::Get()->SingletonGL(aError);
|
||||
if (!gl) {
|
||||
if (aError.IsEmpty()) {
|
||||
aError.Assign("RcANGLE(no shared GL)"_ns);
|
||||
@@ -80,7 +80,7 @@ RenderCompositorANGLE::~RenderCompositorANGLE() {
|
||||
}
|
||||
|
||||
ID3D11Device* RenderCompositorANGLE::GetDeviceOfEGLDisplay(nsACString& aError) {
|
||||
const auto& gl = RenderThread::Get()->SharedGL(aError);
|
||||
const auto& gl = RenderThread::Get()->SingletonGL(aError);
|
||||
if (!gl) {
|
||||
if (aError.IsEmpty()) {
|
||||
aError.Assign("RcANGLE(no shared GL in get device)"_ns);
|
||||
@@ -127,7 +127,7 @@ bool RenderCompositorANGLE::ShutdownEGLLibraryIfNecessary(nsACString& aError) {
|
||||
if ((!displayDevice || device.get() != displayDevice) &&
|
||||
RenderThread::Get()->RendererCount() == 0) {
|
||||
// Shutdown GLLibraryEGL for updating EGLDisplay.
|
||||
RenderThread::Get()->ClearSharedGL();
|
||||
RenderThread::Get()->ClearSingletonGL();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -147,7 +147,7 @@ bool RenderCompositorANGLE::Initialize(nsACString& aError) {
|
||||
aError.Append("(Shutdown EGL)"_ns);
|
||||
return false;
|
||||
}
|
||||
const auto gl = RenderThread::Get()->SharedGL(aError);
|
||||
const auto gl = RenderThread::Get()->SingletonGL(aError);
|
||||
if (!gl) {
|
||||
if (aError.IsEmpty()) {
|
||||
aError.Assign("RcANGLE(no shared GL post maybe shutdown)"_ns);
|
||||
@@ -697,7 +697,7 @@ bool RenderCompositorANGLE::CreateEGLSurface() {
|
||||
|
||||
const auto buffer = reinterpret_cast<EGLClientBuffer>(backBuf.get());
|
||||
|
||||
const auto gl = RenderThread::Get()->SharedGL();
|
||||
const auto gl = RenderThread::Get()->SingletonGL();
|
||||
const auto& gle = gl::GLContextEGL::Cast(gl);
|
||||
const auto& egl = gle->mEgl;
|
||||
const EGLSurface surface = egl->fCreatePbufferFromClientBuffer(
|
||||
|
||||
@@ -48,7 +48,9 @@ class RenderCompositorANGLE : public RenderCompositor {
|
||||
bool Resume() override;
|
||||
void Update() override;
|
||||
|
||||
gl::GLContext* gl() const override { return RenderThread::Get()->SharedGL(); }
|
||||
gl::GLContext* gl() const override {
|
||||
return RenderThread::Get()->SingletonGL();
|
||||
}
|
||||
|
||||
bool MakeCurrent() override;
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ UniquePtr<RenderCompositor> RenderCompositorEGL::Create(
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
if (!RenderThread::Get()->SharedGL()) {
|
||||
if (!RenderThread::Get()->SingletonGL()) {
|
||||
gfxCriticalNote << "Failed to get shared GL context";
|
||||
return nullptr;
|
||||
}
|
||||
@@ -202,7 +202,7 @@ bool RenderCompositorEGL::Resume() {
|
||||
bool RenderCompositorEGL::IsPaused() { return mEGLSurface == EGL_NO_SURFACE; }
|
||||
|
||||
gl::GLContext* RenderCompositorEGL::gl() const {
|
||||
return RenderThread::Get()->SharedGL();
|
||||
return RenderThread::Get()->SingletonGL();
|
||||
}
|
||||
|
||||
bool RenderCompositorEGL::MakeCurrent() {
|
||||
|
||||
@@ -417,7 +417,7 @@ void RenderCompositorNative::AddSurface(
|
||||
/* static */
|
||||
UniquePtr<RenderCompositor> RenderCompositorNativeOGL::Create(
|
||||
RefPtr<widget::CompositorWidget>&& aWidget, nsACString& aError) {
|
||||
RefPtr<gl::GLContext> gl = RenderThread::Get()->SharedGL();
|
||||
RefPtr<gl::GLContext> gl = RenderThread::Get()->SingletonGL();
|
||||
if (!gl) {
|
||||
gl = gl::GLContextProvider::CreateForCompositorWidget(
|
||||
aWidget, /* aWebRender */ true, /* aForceAccelerated */ true);
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace wr {
|
||||
/* static */
|
||||
UniquePtr<RenderCompositor> RenderCompositorOGL::Create(
|
||||
RefPtr<widget::CompositorWidget>&& aWidget, nsACString& aError) {
|
||||
RefPtr<gl::GLContext> gl = RenderThread::Get()->SharedGL();
|
||||
RefPtr<gl::GLContext> gl = RenderThread::Get()->SingletonGL();
|
||||
if (!gl) {
|
||||
gl = gl::GLContextProvider::CreateForCompositorWidget(
|
||||
aWidget, /* aWebRender */ true, /* aForceAccelerated */ true);
|
||||
|
||||
@@ -42,9 +42,9 @@ UniquePtr<RenderCompositor> RenderCompositorOGLSWGL::Create(
|
||||
|
||||
RefPtr<Compositor> compositor;
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
RefPtr<gl::GLContext> context = RenderThread::Get()->SharedGL();
|
||||
RefPtr<gl::GLContext> context = RenderThread::Get()->SingletonGL();
|
||||
if (!context) {
|
||||
gfxCriticalNote << "SharedGL does not exist for SWGL";
|
||||
gfxCriticalNote << "SingletonGL does not exist for SWGL";
|
||||
return nullptr;
|
||||
}
|
||||
nsCString log;
|
||||
|
||||
@@ -50,8 +50,8 @@ ID3D11Texture2D* RenderDXGITextureHost::GetD3D11Texture2DWithGL() {
|
||||
}
|
||||
|
||||
if (!mGL) {
|
||||
// SharedGL is always used on Windows with ANGLE.
|
||||
mGL = RenderThread::Get()->SharedGL();
|
||||
// SingletonGL is always used on Windows with ANGLE.
|
||||
mGL = RenderThread::Get()->SingletonGL();
|
||||
}
|
||||
|
||||
if (!EnsureD3D11Texture2DWithGL()) {
|
||||
|
||||
@@ -143,7 +143,7 @@ void RenderThread::ShutDownTask(layers::SynchronousTask* aTask) {
|
||||
layers::SharedSurfacesParent::Shutdown();
|
||||
|
||||
ClearAllBlobImageResources();
|
||||
ClearSharedGL();
|
||||
ClearSingletonGL();
|
||||
ClearSharedSurfacePool();
|
||||
}
|
||||
|
||||
@@ -764,7 +764,7 @@ RenderTextureHost* RenderThread::GetRenderTexture(
|
||||
|
||||
void RenderThread::InitDeviceTask() {
|
||||
MOZ_ASSERT(IsInRenderThread());
|
||||
MOZ_ASSERT(!mSharedGL);
|
||||
MOZ_ASSERT(!mSingletonGL);
|
||||
|
||||
if (gfx::gfxVars::UseSoftwareWebRender()) {
|
||||
// Ensure we don't instantiate any shared GL context when SW-WR is used.
|
||||
@@ -772,13 +772,13 @@ void RenderThread::InitDeviceTask() {
|
||||
}
|
||||
|
||||
nsAutoCString err;
|
||||
mSharedGL = CreateGLContext(err);
|
||||
mSingletonGL = CreateGLContext(err);
|
||||
if (gfx::gfxVars::UseWebRenderProgramBinaryDisk()) {
|
||||
mProgramCache = MakeUnique<WebRenderProgramCache>(ThreadPool().Raw());
|
||||
}
|
||||
// Query the shared GL context to force the
|
||||
// lazy initialization to happen now.
|
||||
SharedGL();
|
||||
SingletonGL();
|
||||
}
|
||||
|
||||
#ifndef XP_WIN
|
||||
@@ -898,35 +898,35 @@ bool RenderThread::IsHandlingWebRenderError() {
|
||||
return mHandlingWebRenderError;
|
||||
}
|
||||
|
||||
gl::GLContext* RenderThread::SharedGL() {
|
||||
gl::GLContext* RenderThread::SingletonGL() {
|
||||
nsAutoCString err;
|
||||
auto gl = SharedGL(err);
|
||||
auto gl = SingletonGL(err);
|
||||
if (!err.IsEmpty()) {
|
||||
gfxCriticalNote << err.get();
|
||||
}
|
||||
return gl;
|
||||
}
|
||||
|
||||
gl::GLContext* RenderThread::SharedGL(nsACString& aError) {
|
||||
gl::GLContext* RenderThread::SingletonGL(nsACString& aError) {
|
||||
MOZ_ASSERT(IsInRenderThread());
|
||||
if (!mSharedGL) {
|
||||
mSharedGL = CreateGLContext(aError);
|
||||
if (!mSingletonGL) {
|
||||
mSingletonGL = CreateGLContext(aError);
|
||||
mShaders = nullptr;
|
||||
}
|
||||
if (mSharedGL && !mShaders) {
|
||||
mShaders = MakeUnique<WebRenderShaders>(mSharedGL, mProgramCache.get());
|
||||
if (mSingletonGL && !mShaders) {
|
||||
mShaders = MakeUnique<WebRenderShaders>(mSingletonGL, mProgramCache.get());
|
||||
}
|
||||
|
||||
return mSharedGL.get();
|
||||
return mSingletonGL.get();
|
||||
}
|
||||
|
||||
void RenderThread::ClearSharedGL() {
|
||||
void RenderThread::ClearSingletonGL() {
|
||||
MOZ_ASSERT(IsInRenderThread());
|
||||
if (mSurfacePool) {
|
||||
mSurfacePool->DestroyGLResourcesForContext(mSharedGL);
|
||||
mSurfacePool->DestroyGLResourcesForContext(mSingletonGL);
|
||||
}
|
||||
mShaders = nullptr;
|
||||
mSharedGL = nullptr;
|
||||
mSingletonGL = nullptr;
|
||||
}
|
||||
|
||||
RefPtr<layers::SurfacePool> RenderThread::SharedSurfacePool() {
|
||||
|
||||
@@ -255,9 +255,9 @@ class RenderThread final {
|
||||
}
|
||||
|
||||
/// Can only be called from the render thread.
|
||||
gl::GLContext* SharedGL(nsACString& aError);
|
||||
gl::GLContext* SharedGL();
|
||||
void ClearSharedGL();
|
||||
gl::GLContext* SingletonGL(nsACString& aError);
|
||||
gl::GLContext* SingletonGL();
|
||||
void ClearSingletonGL();
|
||||
RefPtr<layers::SurfacePool> SharedSurfacePool();
|
||||
void ClearSharedSurfacePool();
|
||||
|
||||
@@ -322,7 +322,7 @@ class RenderThread final {
|
||||
|
||||
// An optional shared GLContext to be used for all
|
||||
// windows.
|
||||
RefPtr<gl::GLContext> mSharedGL;
|
||||
RefPtr<gl::GLContext> mSingletonGL;
|
||||
|
||||
RefPtr<layers::SurfacePool> mSurfacePool;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user