Bug 1195359 - Use a new display on the compositor thread when using GLX and the GL compositor. r?lsalzman
MozReview-Commit-ID: G4Yd0p9R1fh
--- a/gfx/gl/GLContextProviderGLX.cpp
+++ b/gfx/gl/GLContextProviderGLX.cpp
@@ -1112,17 +1112,17 @@ GLContextProviderGLX::CreateForWindow(ns
// Currently, we take whatever Visual the window already has, and
// try to create an fbconfig for that visual. This isn't
// necessarily what we want in the long run; an fbconfig may not
// be available for the existing visual, or if it is, the GL
// performance might be suboptimal. But using the existing visual
// is a relatively safe intermediate step.
- Display* display = (Display*)aWidget->GetNativeData(NS_NATIVE_DISPLAY);
+ Display* display = (Display*)aWidget->GetNativeData(NS_NATIVE_COMPOSITOR_DISPLAY);
if (!display) {
NS_ERROR("X Display required for GLX Context provider");
return nullptr;
}
int xscreen = DefaultScreen(display);
Window window = GET_NATIVE_WINDOW(aWidget);
--- a/gfx/thebes/gfxPlatformGtk.cpp
+++ b/gfx/thebes/gfxPlatformGtk.cpp
@@ -94,25 +94,40 @@ gfxPlatformGtk::gfxPlatformGtk()
sUseXRender = (GDK_IS_X11_DISPLAY(gdk_display_get_default())) ?
mozilla::Preferences::GetBool("gfx.xrender.enabled") : false;
#endif
uint32_t canvasMask = BackendTypeBit(BackendType::CAIRO) | BackendTypeBit(BackendType::SKIA);
uint32_t contentMask = BackendTypeBit(BackendType::CAIRO) | BackendTypeBit(BackendType::SKIA);
InitBackendPrefs(canvasMask, BackendType::CAIRO,
contentMask, BackendType::CAIRO);
+
+#ifdef MOZ_X11
+ if (GDK_IS_X11_DISPLAY(gdk_display_get_default())) {
+ mCompositorDisplay = XOpenDisplay(nullptr);
+ MOZ_ASSERT(mCompositorDisplay, "Failed to create compositor display!");
+ } else {
+ mCompositorDisplay = nullptr;
+ }
+#endif // MOZ_X11
}
gfxPlatformGtk::~gfxPlatformGtk()
{
if (!sUseFcFontList) {
gfxFontconfigUtils::Shutdown();
sFontconfigUtils = nullptr;
gfxPangoFontGroup::Shutdown();
}
+
+#ifdef MOZ_X11
+ if (mCompositorDisplay) {
+ XCloseDisplay(mCompositorDisplay);
+ }
+#endif // MOZ_X11
}
void
gfxPlatformGtk::FlushContentDrawing()
{
if (UseXRender()) {
XFlush(DefaultXDisplay());
}
--- a/gfx/thebes/gfxPlatformGtk.h
+++ b/gfx/thebes/gfxPlatformGtk.h
@@ -11,16 +11,21 @@
#include "nsTArray.h"
#if (MOZ_WIDGET_GTK == 2)
extern "C" {
typedef struct _GdkDrawable GdkDrawable;
}
#endif
+#ifdef MOZ_X11
+struct _XDisplay;
+typedef struct _XDisplay Display;
+#endif // MOZ_X11
+
class gfxFontconfigUtils;
class gfxPlatformGtk : public gfxPlatform {
public:
gfxPlatformGtk();
virtual ~gfxPlatformGtk();
static gfxPlatformGtk *GetPlatform() {
@@ -133,27 +138,35 @@ public:
bool SupportsPluginDirectBitmapDrawing() override {
return true;
}
#ifdef GL_PROVIDER_GLX
already_AddRefed<mozilla::gfx::VsyncSource> CreateHardwareVsyncSource() override;
#endif
+#ifdef MOZ_X11
+ Display* GetCompositorDisplay() {
+ return mCompositorDisplay;
+ }
+#endif // MOZ_X11
+
protected:
static gfxFontconfigUtils *sFontconfigUtils;
int8_t mMaxGenericSubstitutions;
private:
virtual void GetPlatformCMSOutputProfile(void *&mem,
size_t &size) override;
#ifdef MOZ_X11
static bool sUseXRender;
+
+ Display* mCompositorDisplay;
#endif
// xxx - this will be removed once the new fontconfig platform font list
// replaces gfxPangoFontGroup
static bool sUseFcFontList;
};
#endif /* GFX_PLATFORM_GTK_H */
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -1759,16 +1759,20 @@ nsWindow::GetNativeData(uint32_t aDataTy
}
// If IME context isn't available on this widget, we should set |this|
// instead of nullptr.
if (!mIMContext) {
return this;
}
return mIMContext.get();
}
+#ifdef MOZ_X11
+ case NS_NATIVE_COMPOSITOR_DISPLAY:
+ return gfxPlatformGtk::GetPlatform()->GetCompositorDisplay();
+#endif // MOZ_X11
default:
NS_WARNING("nsWindow::GetNativeData called with bad value");
return nullptr;
}
}
void
nsWindow::SetNativeData(uint32_t aDataType, uintptr_t aVal)
--- a/widget/nsIWidget.h
+++ b/widget/nsIWidget.h
@@ -125,16 +125,19 @@ typedef void* nsNativeWidget;
#define NS_NATIVE_TSF_DISPLAY_ATTR_MGR 102
#define NS_NATIVE_ICOREWINDOW 103 // winrt specific
#define NS_NATIVE_CHILD_WINDOW 104
#define NS_NATIVE_CHILD_OF_SHAREABLE_WINDOW 105
#endif
#if defined(MOZ_WIDGET_GTK)
// set/get nsPluginNativeWindowGtk, e10s specific
#define NS_NATIVE_PLUGIN_OBJECT_PTR 104
+#ifdef MOZ_X11
+#define NS_NATIVE_COMPOSITOR_DISPLAY 105
+#endif // MOZ_X11
#endif
#ifdef MOZ_WIDGET_ANDROID
#define NS_NATIVE_NEW_EGL_SURFACE 100
#define NS_JAVA_SURFACE 101
#endif
#define NS_IWIDGET_IID \
{ 0x06396bf6, 0x2dd8, 0x45e5, \