Bug 1447270 - Fix build failure of cairo-gtk3-wayland
On cairo-gtk3-wayland, GLContextProviderEGL is used by default
instead of GLContextProviderGLX, so GLContextGLX::FindVisual()
isn't defined.
MozReview-Commit-ID: 2UFBxA8F7QW
--- a/gfx/gl/GLContextProvider.h
+++ b/gfx/gl/GLContextProvider.h
@@ -41,16 +41,17 @@ namespace gl {
#define GL_CONTEXT_PROVIDER_DEFAULT GLContextProviderCGL
#endif
#if defined(MOZ_X11) && !defined(MOZ_WAYLAND)
#define GL_CONTEXT_PROVIDER_NAME GLContextProviderGLX
#include "GLContextProviderImpl.h"
#undef GL_CONTEXT_PROVIDER_NAME
#define GL_CONTEXT_PROVIDER_DEFAULT GLContextProviderGLX
+ #define GL_CONTEXT_PROVIDER_IS_GLX 1
#endif
#define GL_CONTEXT_PROVIDER_NAME GLContextProviderEGL
#include "GLContextProviderImpl.h"
#undef GL_CONTEXT_PROVIDER_NAME
#ifndef GL_CONTEXT_PROVIDER_DEFAULT
#define GL_CONTEXT_PROVIDER_DEFAULT GLContextProviderEGL
#endif
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -112,17 +112,19 @@ using namespace mozilla::widget;
#include "GLContextProvider.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/gfx/HelpersCairo.h"
#include "mozilla/gfx/GPUProcessManager.h"
#include "mozilla/layers/CompositorBridgeParent.h"
#include "mozilla/layers/CompositorThread.h"
#ifdef MOZ_X11
+#ifdef GL_CONTEXT_PROVIDER_IS_GLX
#include "GLContextGLX.h" // for GLContextGLX::FindVisual()
+#endif // GL_CONTEXT_PROVIDER_IS_GLX
#include "GtkCompositorWidget.h"
#include "gfxXlibSurface.h"
#include "WindowSurfaceX11Image.h"
#include "WindowSurfaceX11SHM.h"
#include "WindowSurfaceXRender.h"
#endif // MOZ_X11
#ifdef MOZ_WAYLAND
#include "nsIClipboard.h"
@@ -134,17 +136,20 @@ using namespace mozilla::widget;
#include <dlfcn.h>
using namespace mozilla;
using namespace mozilla::gfx;
using namespace mozilla::widget;
using namespace mozilla::layers;
using mozilla::gl::GLContext;
+#ifdef GL_CONTEXT_PROVIDER_IS_GLX
using mozilla::gl::GLContextGLX;
+#endif // GL_CONTEXT_PROVIDER_IS_GLX
+
// Don't put more than this many rects in the dirty region, just fluff
// out to the bounding-box if there are more
#define MAX_RECTS_IN_REGION 100
const gint kEvents = GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK |
GDK_VISIBILITY_NOTIFY_MASK |
GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK |
@@ -3644,31 +3649,33 @@ nsWindow::Create(nsIWidget* aParent,
bool useWebRender = gfxPlatform::Initialized() &&
gfx::gfxVars::UseWebRender() &&
AllowWebRenderForThisWindow();
// If using WebRender on X11, we need to select a visual with a depth buffer,
// as well as an alpha channel if transparency is requested. This must be done
// before the widget is realized.
if (mIsX11Display && useWebRender) {
+#ifdef GL_CONTEXT_PROVIDER_IS_GLX
auto display =
GDK_DISPLAY_XDISPLAY(gtk_widget_get_display(mShell));
auto screen = gtk_widget_get_screen(mShell);
int screenNumber = GDK_SCREEN_XNUMBER(screen);
int visualId = 0;
if (GLContextGLX::FindVisual(display, screenNumber,
useWebRender, useAlphaVisual,
&visualId)) {
// If we're using CSD, rendering will go through mContainer, but
// it will inherit this visual as it is a child of mShell.
gtk_widget_set_visual(mShell,
gdk_x11_screen_lookup_visual(screen,
visualId));
}
+#endif // GL_CONTEXT_PROVIDER_IS_GLX
} else if (useAlphaVisual) {
GdkScreen *screen = gtk_widget_get_screen(mShell);
if (gdk_screen_is_composited(screen)) {
GdkVisual *visual = gdk_screen_get_rgba_visual(screen);
gtk_widget_set_visual(mShell, visual);
}
}