@@ -171,13 +171,10 @@ static std::shared_ptr<EglDisplay> GetAndInitDisplay(
171
171
172
172
#ifdef MOZ_WIDGET_GTK
173
173
static std::shared_ptr<EglDisplay> GetAndInitDeviceDisplay (
174
- GLLibraryEGL& egl, const StaticMutexAutoLock& aProofOfLock,
175
- bool useDrmRenderDevice) {
174
+ GLLibraryEGL& egl, const StaticMutexAutoLock& aProofOfLock) {
176
175
nsAutoCString drmRenderDevice (gfx::gfxVars::DrmRenderDevice ());
177
- if (!useDrmRenderDevice) {
178
- drmRenderDevice = " " ;
179
- }
180
- if (!egl.IsExtensionSupported (EGLLibExtension::EXT_platform_device) ||
176
+ if (drmRenderDevice.IsEmpty () ||
177
+ !egl.IsExtensionSupported (EGLLibExtension::EXT_platform_device) ||
181
178
!egl.IsExtensionSupported (EGLLibExtension::EXT_device_enumeration)) {
182
179
return nullptr ;
183
180
}
@@ -198,9 +195,8 @@ static std::shared_ptr<EglDisplay> GetAndInitDeviceDisplay(
198
195
for (const auto & device : devices) {
199
196
const char * renderNodeString =
200
197
egl.fQueryDeviceStringEXT (device, LOCAL_EGL_DRM_RENDER_NODE_FILE_EXT);
201
- // We are looking for a specific device, skip others
202
- if (strcmp (renderNodeString ? renderNodeString : " " ,
203
- drmRenderDevice.get ()) == 0 ) {
198
+ if (renderNodeString &&
199
+ strcmp (renderNodeString, drmRenderDevice.get ()) == 0 ) {
204
200
const EGLAttrib attrib_list[] = {LOCAL_EGL_NONE};
205
201
display = egl.fGetPlatformDisplay (LOCAL_EGL_PLATFORM_DEVICE_EXT, device,
206
202
attrib_list);
@@ -896,36 +892,28 @@ std::shared_ptr<EglDisplay> GLLibraryEGL::CreateDisplayLocked(
896
892
}
897
893
}
898
894
} else {
895
+ void * nativeDisplay = EGL_DEFAULT_DISPLAY;
899
896
#ifdef MOZ_WIDGET_GTK
900
- // Check if we allow hardware rendering for WebGL
901
- if (gfx::gfxVars::WebglUseHardware ()) {
902
- // Initialize the display the normal way
903
- if (gdk_display_get_default ()) {
904
- void * nativeDisplay = EGL_DEFAULT_DISPLAY;
897
+ if (!gdk_display_get_default ()) {
898
+ ret = GetAndInitDeviceDisplay (*this , aProofOfLock);
899
+ if (!ret) {
900
+ ret = GetAndInitSurfacelessDisplay (*this , aProofOfLock);
901
+ }
902
+ }
905
903
# ifdef MOZ_WAYLAND
906
- if (widget::GdkIsWaylandDisplay ()) {
907
- // Wayland does not support EGL_DEFAULT_DISPLAY
908
- nativeDisplay = widget::WaylandDisplayGetWLDisplay ();
909
- if (!nativeDisplay) {
910
- NS_WARNING (" Failed to get wl_display." );
911
- return nullptr ;
912
- }
913
- }
914
- # endif
915
- ret = GetAndInitDisplay (*this , nativeDisplay, aProofOfLock);
916
- } else {
917
- // Enumerate EGL devices to find the chosen drm render device
918
- ret = GetAndInitDeviceDisplay (*this , aProofOfLock, true );
919
- // Try a mesa surfaceless display
920
- if (!ret) {
921
- ret = GetAndInitSurfacelessDisplay (*this , aProofOfLock);
922
- }
904
+ else if (widget::GdkIsWaylandDisplay ()) {
905
+ // Wayland does not support EGL_DEFAULT_DISPLAY
906
+ nativeDisplay = widget::WaylandDisplayGetWLDisplay ();
907
+ if (!nativeDisplay) {
908
+ NS_WARNING (" Failed to get wl_display." );
909
+ return nullptr ;
923
910
}
924
- } else {
925
- // Initialize a swrast egl device such as llvmpipe
926
- ret = GetAndInitDeviceDisplay (*this , aProofOfLock, false );
927
911
}
912
+ # endif
928
913
#endif
914
+ if (!ret) {
915
+ ret = GetAndInitDisplay (*this , nativeDisplay, aProofOfLock);
916
+ }
929
917
}
930
918
931
919
if (!ret) {
0 commit comments