From f1bbfe6ec34f6f057427938258da751972efb471 Mon Sep 17 00:00:00 2001 From: Martin Stransky Date: Thu, 20 Jun 2019 21:52:40 +0000 Subject: [PATCH] Bug 1557265 - Remove HAVE_LIBDRM defines as libdrm is mandatory now, r=glandium Depends on D33918 Differential Revision: https://phabricator.services.mozilla.com/D34857 --HG-- extra : moz-landing-system : lando --- widget/gtk/WindowSurfaceWayland.cpp | 6 ------ widget/gtk/WindowSurfaceWayland.h | 6 +----- widget/gtk/moz.build | 8 +------- widget/gtk/nsWaylandDisplay.cpp | 23 +++-------------------- widget/gtk/nsWaylandDisplay.h | 18 ++++-------------- 5 files changed, 9 insertions(+), 52 deletions(-) diff --git a/widget/gtk/WindowSurfaceWayland.cpp b/widget/gtk/WindowSurfaceWayland.cpp index 58a48e8724d4..5c877b83558c 100644 --- a/widget/gtk/WindowSurfaceWayland.cpp +++ b/widget/gtk/WindowSurfaceWayland.cpp @@ -415,7 +415,6 @@ already_AddRefed WindowBackBufferShm::Lock() { BUFFER_BPP * mWidth, GetSurfaceFormat()); } -#ifdef HAVE_LIBDRM WindowBackBufferDMABuf::WindowBackBufferDMABuf( nsWaylandDisplay* aWaylandDisplay, int aWidth, int aHeight) : WindowBackBuffer(aWaylandDisplay) { @@ -478,7 +477,6 @@ void WindowBackBufferDMABuf::Detach(wl_buffer* aBuffer) { } void WindowBackBufferDMABuf::Clear() { mDMAbufSurface.Clear(); } -#endif static void frame_callback_handler(void* data, struct wl_callback* callback, uint32_t time) { @@ -534,12 +532,10 @@ WindowSurfaceWayland::~WindowSurfaceWayland() { bool WindowSurfaceWayland::UseDMABufBackend() { if (!mUseDMABufInitialized) { -#ifdef HAVE_LIBDRM if (WaylandDMABufSurface::IsAvailable()) { mUseDMABuf = nsWaylandDisplay::IsDMABufEnabled(); LOGWAYLAND(("%s DMABuf state %d\n", __PRETTY_FUNCTION__, mUseDMABuf)); } -#endif mUseDMABufInitialized = true; } return mUseDMABuf; @@ -547,7 +543,6 @@ bool WindowSurfaceWayland::UseDMABufBackend() { WindowBackBuffer* WindowSurfaceWayland::CreateWaylandBuffer(int aWidth, int aHeight) { -#ifdef HAVE_LIBDRM if (UseDMABufBackend()) { static bool sDMABufBufferCreated = false; WindowBackBuffer* buffer = @@ -567,7 +562,6 @@ WindowBackBuffer* WindowSurfaceWayland::CreateWaylandBuffer(int aWidth, mUseDMABuf = false; } } -#endif return new WindowBackBufferShm(mWaylandDisplay, aWidth, aHeight); } diff --git a/widget/gtk/WindowSurfaceWayland.h b/widget/gtk/WindowSurfaceWayland.h index b6a5b7dd1b41..26766695205a 100644 --- a/widget/gtk/WindowSurfaceWayland.h +++ b/widget/gtk/WindowSurfaceWayland.h @@ -10,9 +10,7 @@ #include #include "mozilla/gfx/Types.h" #include "nsWaylandDisplay.h" -#ifdef HAVE_LIBDRM -# include "WaylandDMABufSurface.h" -#endif +#include "WaylandDMABufSurface.h" #define BACK_BUFFER_NUM 2 @@ -121,7 +119,6 @@ class WindowBackBufferShm : public WindowBackBuffer { bool mIsLocked; }; -#ifdef HAVE_LIBDRM class WindowBackBufferDMABuf : public WindowBackBuffer { public: WindowBackBufferDMABuf(nsWaylandDisplay* aWaylandDisplay, int aWidth, @@ -148,7 +145,6 @@ class WindowBackBufferDMABuf : public WindowBackBuffer { private: WaylandDMABufSurface mDMAbufSurface; }; -#endif class WindowImageSurface { public: diff --git a/widget/gtk/moz.build b/widget/gtk/moz.build index cb9ac2c8a2fc..8fc27c1db6ca 100644 --- a/widget/gtk/moz.build +++ b/widget/gtk/moz.build @@ -99,17 +99,11 @@ if CONFIG['MOZ_WAYLAND']: UNIFIED_SOURCES += [ 'nsClipboardWayland.cpp', 'nsWaylandDisplay.cpp', + 'WaylandDMABufSurface.cpp', 'WindowSurfaceWayland.cpp', ] EXPORTS.mozilla.widget += [ 'nsWaylandDisplay.h', - ] - -if CONFIG['MOZ_WAYLAND'] and CONFIG['HAVE_LIBDRM']: - SOURCES += [ - 'WaylandDMABufSurface.cpp', - ] - EXPORTS.mozilla.widget += [ 'WaylandDMABufSurface.h', ] diff --git a/widget/gtk/nsWaylandDisplay.cpp b/widget/gtk/nsWaylandDisplay.cpp index 50586ff2c23f..2c934b73384f 100644 --- a/widget/gtk/nsWaylandDisplay.cpp +++ b/widget/gtk/nsWaylandDisplay.cpp @@ -13,10 +13,8 @@ namespace widget { #define GBMLIB_NAME "libgbm.so.1" #define DRMLIB_NAME "libdrm.so.2" -#ifdef HAVE_LIBDRM bool nsWaylandDisplay::mIsDMABufEnabled; bool nsWaylandDisplay::mIsDMABufPrefLoaded; -#endif // nsWaylandDisplay needs to be created for each calling thread(main thread, // compositor thread and render thread) @@ -116,7 +114,6 @@ void nsWaylandDisplay::SetPrimarySelectionDeviceManager( mPrimarySelectionDeviceManager = aPrimarySelectionDeviceManager; } -#ifdef HAVE_LIBDRM void nsWaylandDisplay::SetDmabuf(zwp_linux_dmabuf_v1* aDmabuf) { mDmabuf = aDmabuf; } @@ -166,7 +163,6 @@ static void dmabuf_format(void* data, static const struct zwp_linux_dmabuf_v1_listener dmabuf_listener = { dmabuf_format, dmabuf_modifiers}; -#endif static void global_registry_handler(void* data, wl_registry* registry, uint32_t id, const char* interface, @@ -205,15 +201,12 @@ static void global_registry_handler(void* data, wl_registry* registry, wl_proxy_set_queue((struct wl_proxy*)subcompositor, display->GetEventQueue()); display->SetSubcompositor(subcompositor); - } -#ifdef HAVE_LIBDRM - else if (strcmp(interface, "zwp_linux_dmabuf_v1") == 0 && version > 2) { + } else if (strcmp(interface, "zwp_linux_dmabuf_v1") == 0 && version > 2) { auto dmabuf = static_cast( wl_registry_bind(registry, id, &zwp_linux_dmabuf_v1_interface, 3)); display->SetDmabuf(dmabuf); zwp_linux_dmabuf_v1_add_listener(dmabuf, &dmabuf_listener, data); } -#endif } static void global_registry_remover(void* data, wl_registry* registry, @@ -231,7 +224,6 @@ bool nsWaylandDisplay::Matches(wl_display* aDisplay) { return mThreadId == PR_GetCurrentThread() && aDisplay == mDisplay; } -#ifdef HAVE_LIBDRM bool nsWaylandDisplay::ConfigureGbm() { if (!nsGbmLib::IsAvailable()) { return false; @@ -279,7 +271,6 @@ int nsWaylandDisplay::GetGbmDeviceFd() { } return mGbmFd; } -#endif nsWaylandDisplay::nsWaylandDisplay(wl_display* aDisplay) : mDispatcherThreadLoop(nullptr), @@ -291,28 +282,22 @@ nsWaylandDisplay::nsWaylandDisplay(wl_display* aDisplay) mSeat(nullptr), mShm(nullptr), mPrimarySelectionDeviceManager(nullptr), - mRegistry(nullptr) -#ifdef HAVE_LIBDRM - , + mRegistry(nullptr), mGbmDevice(nullptr), mGbmFd(-1), mXRGBFormat({false, false, -1, nullptr, 0}), mARGBFormat({false, false, -1, nullptr, 0}), mGdmConfigured(false), - mExplicitSync(false) -#endif -{ + mExplicitSync(false) { mRegistry = wl_display_get_registry(mDisplay); wl_registry_add_listener(mRegistry, ®istry_listener, this); if (NS_IsMainThread()) { -#ifdef HAVE_LIBDRM if (!mIsDMABufPrefLoaded) { mIsDMABufPrefLoaded = true; mIsDMABufEnabled = Preferences::GetBool("widget.wayland_dmabuf_backend.enabled", false); } -#endif // Use default event queue in main thread operated by Gtk+. mEventQueue = nullptr; wl_display_roundtrip(mDisplay); @@ -341,7 +326,6 @@ nsWaylandDisplay::~nsWaylandDisplay() { } } -#ifdef HAVE_LIBDRM void* nsGbmLib::sGbmLibHandle = nullptr; void* nsGbmLib::sXf86DrmLibHandle = nullptr; bool nsGbmLib::sLibLoaded = false; @@ -422,7 +406,6 @@ bool nsGbmLib::Load() { return sGbmLibHandle; } -#endif } // namespace widget } // namespace mozilla diff --git a/widget/gtk/nsWaylandDisplay.h b/widget/gtk/nsWaylandDisplay.h index ac97cf7c1c53..97e160907ae3 100644 --- a/widget/gtk/nsWaylandDisplay.h +++ b/widget/gtk/nsWaylandDisplay.h @@ -15,12 +15,10 @@ #include "base/task.h" // for NewRunnableMethod, etc #include "mozilla/StaticMutex.h" -#ifdef HAVE_LIBDRM -# include -# include -# include -# include "mozilla/widget/linux-dmabuf-unstable-v1-client-protocol.h" -#endif +#include +#include +#include +#include "mozilla/widget/linux-dmabuf-unstable-v1-client-protocol.h" namespace mozilla { namespace widget { @@ -65,7 +63,6 @@ class nsWaylandDisplay { void Shutdown(); -#ifdef HAVE_LIBDRM void SetDmabuf(zwp_linux_dmabuf_v1* aDmabuf); zwp_linux_dmabuf_v1* GetDmabuf() { return mDmabuf; }; gbm_device* GetGbmDevice(); @@ -76,12 +73,9 @@ class nsWaylandDisplay { void AddFormatModifier(bool aHasAlpha, int aFormat, uint32_t mModifierHi, uint32_t mModifierLo); static bool IsDMABufEnabled() { return mIsDMABufEnabled; }; -#endif private: -#ifdef HAVE_LIBDRM bool ConfigureGbm(); -#endif MessageLoop* mDispatcherThreadLoop; PRThread* mThreadId; @@ -93,7 +87,6 @@ class nsWaylandDisplay { wl_shm* mShm; gtk_primary_selection_device_manager* mPrimarySelectionDeviceManager; wl_registry* mRegistry; -#ifdef HAVE_LIBDRM zwp_linux_dmabuf_v1* mDmabuf; gbm_device* mGbmDevice; int mGbmFd; @@ -103,14 +96,12 @@ class nsWaylandDisplay { bool mExplicitSync; static bool mIsDMABufEnabled; static bool mIsDMABufPrefLoaded; -#endif }; void WaylandDispatchDisplays(); void WaylandDisplayShutdown(); nsWaylandDisplay* WaylandDisplayGet(GdkDisplay* aGdkDisplay = nullptr); -#ifdef HAVE_LIBDRM typedef struct gbm_device* (*CreateDeviceFunc)(int); typedef struct gbm_bo* (*CreateFunc)(struct gbm_device*, uint32_t, uint32_t, uint32_t, uint32_t); @@ -199,7 +190,6 @@ class nsGbmLib { static void* sXf86DrmLibHandle; static bool sLibLoaded; }; -#endif } // namespace widget } // namespace mozilla