Bug 1578380 - [Wayland] Provide gfxPlatformGtk::IsX11Display() and gfxPlatformGtk::UseWaylandDMABufSurfaces(), r=sotaro

Let's use single Wayland configuration point at gfxPlatformGtk instead of various GDK_IS_X11_DISPLAY() calls.
Also provide info about enabled DMABuf surfaces when Wayland backend is used.

Depends on D46842

Differential Revision: https://phabricator.services.mozilla.com/D46843

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Martin Stransky 2019-09-24 11:35:29 +00:00
Родитель a33bdb4e60
Коммит 06bc3c7598
2 изменённых файлов: 20 добавлений и 7 удалений

Просмотреть файл

@ -54,6 +54,7 @@
# ifdef MOZ_WAYLAND
# include <gdk/gdkwayland.h>
# include "mozilla/widget/nsWaylandDisplay.h"
# endif
#endif /* MOZ_X11 */
@ -80,11 +81,11 @@ gfxPlatformGtk::gfxPlatformGtk() {
}
mMaxGenericSubstitutions = UNINITIALIZED_VALUE;
mIsX11Display = GDK_IS_X11_DISPLAY(gdk_display_get_default());
#ifdef MOZ_X11
if (!gfxPlatform::IsHeadless() && XRE_IsParentProcess()) {
if (GDK_IS_X11_DISPLAY(gdk_display_get_default()) &&
mozilla::Preferences::GetBool("gfx.xrender.enabled")) {
if (mIsX11Display && mozilla::Preferences::GetBool("gfx.xrender.enabled")) {
gfxVars::SetUseXRender(true);
}
}
@ -93,8 +94,7 @@ gfxPlatformGtk::gfxPlatformGtk() {
InitBackendPrefs(GetBackendPrefs());
#ifdef MOZ_X11
if (gfxPlatform::IsHeadless() &&
GDK_IS_X11_DISPLAY(gdk_display_get_default())) {
if (gfxPlatform::IsHeadless() && mIsX11Display) {
mCompositorDisplay = XOpenDisplay(nullptr);
MOZ_ASSERT(mCompositorDisplay, "Failed to create compositor display!");
} else {
@ -132,7 +132,7 @@ void gfxPlatformGtk::FlushContentDrawing() {
void gfxPlatformGtk::InitPlatformGPUProcessPrefs() {
#ifdef MOZ_WAYLAND
if (!GDK_IS_X11_DISPLAY(gdk_display_get_default())) {
if (!mIsX11Display) {
FeatureState& gpuProc = gfxConfig::GetFeature(Feature::GPU_PROCESS);
gpuProc.ForceDisable(FeatureStatus::Blocked,
"Wayland does not work in the GPU process",
@ -353,7 +353,7 @@ void gfxPlatformGtk::GetPlatformCMSOutputProfile(void*& mem, size_t& size) {
#ifdef MOZ_X11
GdkDisplay* display = gdk_display_get_default();
if (!GDK_IS_X11_DISPLAY(display)) return;
if (!mIsX11Display) return;
const char EDID1_ATOM_NAME[] = "XFree86_DDC_EDID1_RAWDATA";
const char ICC_PROFILE_ATOM_NAME[] = "_ICC_PROFILE";
@ -745,7 +745,7 @@ class GtkVsyncSource final : public VsyncSource {
already_AddRefed<gfx::VsyncSource> gfxPlatformGtk::CreateHardwareVsyncSource() {
# ifdef MOZ_WAYLAND
if (!GDK_IS_X11_DISPLAY(gdk_display_get_default())) {
if (!mIsX11Display) {
RefPtr<VsyncSource> vsyncSource = new GtkVsyncSource();
VsyncSource::Display& display = vsyncSource->GetGlobalDisplay();
static_cast<GtkVsyncSource::GLXDisplay&>(display).SetupWayland();
@ -773,3 +773,12 @@ already_AddRefed<gfx::VsyncSource> gfxPlatformGtk::CreateHardwareVsyncSource() {
}
#endif
#ifdef MOZ_WAYLAND
bool gfxPlatformGtk::UseWaylandDMABufSurfaces() {
if (mIsX11Display) {
return false;
}
return widget::nsWaylandDisplay::IsDMABufEnabled();
}
#endif

Просмотреть файл

@ -101,8 +101,11 @@ class gfxPlatformGtk : public gfxPlatform {
mWaylandFrameDelay = aFrameDelay;
}
int64_t GetWaylandFrameDelay() { return mWaylandFrameDelay; }
bool UseWaylandDMABufSurfaces();
#endif
bool IsX11Display() { return mIsX11Display; }
protected:
void InitPlatformGPUProcessPrefs() override;
bool CheckVariationFontSupport() override;
@ -112,6 +115,7 @@ class gfxPlatformGtk : public gfxPlatform {
private:
void GetPlatformCMSOutputProfile(void*& mem, size_t& size) override;
bool mIsX11Display;
#ifdef MOZ_X11
Display* mCompositorDisplay;
#endif