From 06bc3c759876a459e8340dc31b6374651ecb4287 Mon Sep 17 00:00:00 2001 From: Martin Stransky Date: Tue, 24 Sep 2019 11:35:29 +0000 Subject: [PATCH] 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 --- gfx/thebes/gfxPlatformGtk.cpp | 23 ++++++++++++++++------- gfx/thebes/gfxPlatformGtk.h | 4 ++++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/gfx/thebes/gfxPlatformGtk.cpp b/gfx/thebes/gfxPlatformGtk.cpp index 55c60c119e69..6a41fc7401d1 100644 --- a/gfx/thebes/gfxPlatformGtk.cpp +++ b/gfx/thebes/gfxPlatformGtk.cpp @@ -54,6 +54,7 @@ # ifdef MOZ_WAYLAND # include +# 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 gfxPlatformGtk::CreateHardwareVsyncSource() { # ifdef MOZ_WAYLAND - if (!GDK_IS_X11_DISPLAY(gdk_display_get_default())) { + if (!mIsX11Display) { RefPtr vsyncSource = new GtkVsyncSource(); VsyncSource::Display& display = vsyncSource->GetGlobalDisplay(); static_cast(display).SetupWayland(); @@ -773,3 +773,12 @@ already_AddRefed gfxPlatformGtk::CreateHardwareVsyncSource() { } #endif + +#ifdef MOZ_WAYLAND +bool gfxPlatformGtk::UseWaylandDMABufSurfaces() { + if (mIsX11Display) { + return false; + } + return widget::nsWaylandDisplay::IsDMABufEnabled(); +} +#endif diff --git a/gfx/thebes/gfxPlatformGtk.h b/gfx/thebes/gfxPlatformGtk.h index bac14b6aeade..f51e64e9c903 100644 --- a/gfx/thebes/gfxPlatformGtk.h +++ b/gfx/thebes/gfxPlatformGtk.h @@ -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