Bug 1882779 [Linux] Always create offscreen rendering surface if we're missing native rendering window r=lsalzman,jgilbert

Differential Revision: https://phabricator.services.mozilla.com/D204066
This commit is contained in:
stransky 2024-03-21 15:14:17 +00:00
parent fd48b38646
commit bb252b6267

View File

@ -336,23 +336,29 @@ EGLSurface GLContextEGL::CreateEGLSurfaceForCompositorWidget(
}
MOZ_ASSERT(aCompositorWidget);
#ifdef MOZ_WAYLAND
// RenderCompositorEGL does not like EGL_NO_SURFACE as it fallbacks
// to SW rendering or claims itself as paused.
// In case we're missing valid native window because aCompositorWidget hidden,
// just create a fallback EGLSurface.
// Actual EGLSurface will be created by widget code later when
// aCompositorWidget becomes visible.
if (widget::GdkIsWaylandDisplay() && aCompositorWidget->IsHidden()) {
mozilla::gfx::IntSize pbSize(16, 16);
return CreateWaylandOffscreenSurface(*egl, aConfig, pbSize);
}
#endif
EGLNativeWindowType window =
GET_NATIVE_WINDOW_FROM_COMPOSITOR_WIDGET(aCompositorWidget);
if (!window) {
#ifdef MOZ_WIDGET_GTK
// RenderCompositorEGL does not like EGL_NO_SURFACE as it fallbacks
// to SW rendering or claims itself as paused.
// In case we're missing valid native window because aCompositorWidget
// hidden, just create a fallback EGLSurface. Actual EGLSurface will be
// created by widget code later when aCompositorWidget becomes visible.
mozilla::gfx::IntSize pbSize(16, 16);
# ifdef MOZ_WAYLAND
if (GdkIsWaylandDisplay()) {
return CreateWaylandOffscreenSurface(*egl, aConfig, pbSize);
} else
# endif
{
return CreatePBufferSurfaceTryingPowerOfTwo(*egl, aConfig, LOCAL_EGL_NONE,
pbSize);
}
#else
gfxCriticalNote << "window is null";
return EGL_NO_SURFACE;
#endif
}
return mozilla::gl::CreateSurfaceFromNativeWindow(*egl, window, aConfig);
@ -486,16 +492,6 @@ bool GLContextEGL::RenewSurface(CompositorWidget* aWidget) {
EGLNativeWindowType nativeWindow =
GET_NATIVE_WINDOW_FROM_COMPOSITOR_WIDGET(aWidget);
#ifdef MOZ_WAYLAND
// In case we're missing native window on Wayland CompositorWidget is hidden.
// Don't create a fallback EGL surface but fails here.
// We need to repeat RenewSurface() when native window is available
// (CompositorWidget becomes visible).
if (GdkIsWaylandDisplay()) {
NS_WARNING("Failed to get native window");
return false;
}
#endif
if (nativeWindow) {
mSurface = mozilla::gl::CreateSurfaceFromNativeWindow(*mEgl, nativeWindow,
mSurfaceConfig);