Bug 1557265 - Remove HAVE_LIBDRM defines as libdrm is mandatory now, r=glandium
☠☠ backed out by 7034f38fc207 ☠ ☠
authorMartin Stransky <stransky@redhat.com>
Thu, 20 Jun 2019 18:05:27 +0000
changeset 479365 f10c947516e07370615fe8534f81255093f844db
parent 479364 f7e5ef31a50b7b9080f28a53150f16b393d448db
child 479366 5e797f74091ad5195fda457ba351902128ab52ab
push id88243
push useraiakab@mozilla.com
push dateThu, 20 Jun 2019 18:38:36 +0000
treeherderautoland@5e797f74091a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1557265
milestone69.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1557265 - Remove HAVE_LIBDRM defines as libdrm is mandatory now, r=glandium Depends on D33918 Differential Revision: https://phabricator.services.mozilla.com/D34857
widget/gtk/WindowSurfaceWayland.cpp
widget/gtk/WindowSurfaceWayland.h
widget/gtk/moz.build
widget/gtk/nsWaylandDisplay.cpp
widget/gtk/nsWaylandDisplay.h
--- a/widget/gtk/WindowSurfaceWayland.cpp
+++ b/widget/gtk/WindowSurfaceWayland.cpp
@@ -410,17 +410,16 @@ already_AddRefed<gfx::DrawTarget> Window
 
   gfx::IntSize lockSize(mWidth, mHeight);
   mIsLocked = true;
   return gfxPlatform::CreateDrawTargetForData(
       static_cast<unsigned char*>(mShmPool.GetImageData()), lockSize,
       BUFFER_BPP * mWidth, GetSurfaceFormat());
 }
 
-#ifdef HAVE_LIBDRM
 WindowBackBufferDMABuf::WindowBackBufferDMABuf(
     nsWaylandDisplay* aWaylandDisplay, int aWidth, int aHeight)
     : WindowBackBuffer(aWaylandDisplay) {
   mDMAbufSurface.Create(aWidth, aHeight);
 
   LOGWAYLAND(("%s [%p] Created DMABuf buffer [%d x %d]\n", __PRETTY_FUNCTION__,
               (void*)this, aWidth, aHeight));
 }
@@ -473,17 +472,16 @@ bool WindowBackBufferDMABuf::SetImageDat
   return true;
 }
 
 void WindowBackBufferDMABuf::Detach(wl_buffer* aBuffer) {
   mDMAbufSurface.WLBufferDetach();
 }
 
 void WindowBackBufferDMABuf::Clear() { mDMAbufSurface.Clear(); }
-#endif
 
 static void frame_callback_handler(void* data, struct wl_callback* callback,
                                    uint32_t time) {
   auto surface = reinterpret_cast<WindowSurfaceWayland*>(data);
   surface->FrameCallbackHandler();
 
   gfxPlatformGtk::GetPlatform()->SetWaylandLastVsync(time);
 }
@@ -529,30 +527,27 @@ WindowSurfaceWayland::~WindowSurfaceWayl
     if (mBackupBuffer[i]) {
       delete mBackupBuffer[i];
     }
   }
 }
 
 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;
 }
 
 WindowBackBuffer* WindowSurfaceWayland::CreateWaylandBuffer(int aWidth,
                                                             int aHeight) {
-#ifdef HAVE_LIBDRM
   if (UseDMABufBackend()) {
     static bool sDMABufBufferCreated = false;
     WindowBackBuffer* buffer =
         new WindowBackBufferDMABuf(mWaylandDisplay, aWidth, aHeight);
     if (buffer) {
       sDMABufBufferCreated = true;
       return buffer;
     }
@@ -562,17 +557,16 @@ WindowBackBuffer* WindowSurfaceWayland::
     if (sDMABufBufferCreated) {
       NS_WARNING("Failed to allocate DMABuf buffer!");
       return nullptr;
     } else {
       NS_WARNING("Wayland DMABuf failed, switched back to Shm backend!");
       mUseDMABuf = false;
     }
   }
-#endif
 
   return new WindowBackBufferShm(mWaylandDisplay, aWidth, aHeight);
 }
 
 WindowBackBuffer* WindowSurfaceWayland::GetWaylandBufferToDraw(
     int aWidth, int aHeight, bool aFullScreenUpdate) {
   LOGWAYLAND(("%s [%p] Requested buffer [%d x %d]\n", __PRETTY_FUNCTION__,
               (void*)this, aWidth, aHeight));
--- a/widget/gtk/WindowSurfaceWayland.h
+++ b/widget/gtk/WindowSurfaceWayland.h
@@ -5,19 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef _MOZILLA_WIDGET_GTK_WINDOW_SURFACE_WAYLAND_H
 #define _MOZILLA_WIDGET_GTK_WINDOW_SURFACE_WAYLAND_H
 
 #include <prthread.h>
 #include "mozilla/gfx/Types.h"
 #include "nsWaylandDisplay.h"
-#ifdef HAVE_LIBDRM
-#  include "WaylandDMABufSurface.h"
-#endif
+#include "WaylandDMABufSurface.h"
 
 #define BACK_BUFFER_NUM 2
 
 namespace mozilla {
 namespace widget {
 
 // Allocates and owns shared memory for Wayland drawing surface
 class WaylandShmPool {
@@ -116,17 +114,16 @@ class WindowBackBufferShm : public Windo
   // and passes it to wayland compositor by wl_surface object.
   wl_buffer* mWaylandBuffer;
   int mWidth;
   int mHeight;
   bool mAttached;
   bool mIsLocked;
 };
 
-#ifdef HAVE_LIBDRM
 class WindowBackBufferDMABuf : public WindowBackBuffer {
  public:
   WindowBackBufferDMABuf(nsWaylandDisplay* aWaylandDisplay, int aWidth,
                          int aHeight);
   ~WindowBackBufferDMABuf();
 
   bool IsAttached();
   void SetAttached();
@@ -143,17 +140,16 @@ class WindowBackBufferDMABuf : public Wi
 
   void Clear();
   void Detach(wl_buffer* aBuffer);
   bool Resize(int aWidth, int aHeight);
 
  private:
   WaylandDMABufSurface mDMAbufSurface;
 };
-#endif
 
 class WindowImageSurface {
  public:
   static void Draw(gfx::SourceSurface* aSurface, gfx::DrawTarget* aDest,
                    const LayoutDeviceIntRegion& aRegion);
 
   void Draw(gfx::DrawTarget* aDest,
             LayoutDeviceIntRegion& aWaylandBufferDamage);
--- a/widget/gtk/moz.build
+++ b/widget/gtk/moz.build
@@ -94,27 +94,21 @@ if CONFIG['MOZ_X11']:
     EXPORTS.mozilla.widget += [
         'WindowSurfaceProvider.h',
     ]
 
 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',
     ]
 
 if CONFIG['ACCESSIBILITY']:
     UNIFIED_SOURCES += [
         'maiRedundantObjectFactory.c',
     ]
 
--- a/widget/gtk/nsWaylandDisplay.cpp
+++ b/widget/gtk/nsWaylandDisplay.cpp
@@ -8,20 +8,18 @@
 #include "nsWaylandDisplay.h"
 
 namespace mozilla {
 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)
 #define MAX_DISPLAY_CONNECTIONS 3
 
 static nsWaylandDisplay* gWaylandDisplays[MAX_DISPLAY_CONNECTIONS];
 static StaticMutex gWaylandDisplaysMutex;
 
@@ -111,17 +109,16 @@ void nsWaylandDisplay::SetDataDeviceMana
 
 void nsWaylandDisplay::SetSeat(wl_seat* aSeat) { mSeat = aSeat; }
 
 void nsWaylandDisplay::SetPrimarySelectionDeviceManager(
     gtk_primary_selection_device_manager* aPrimarySelectionDeviceManager) {
   mPrimarySelectionDeviceManager = aPrimarySelectionDeviceManager;
 }
 
-#ifdef HAVE_LIBDRM
 void nsWaylandDisplay::SetDmabuf(zwp_linux_dmabuf_v1* aDmabuf) {
   mDmabuf = aDmabuf;
 }
 
 GbmFormat* nsWaylandDisplay::GetGbmFormat(bool aHasAlpha) {
   GbmFormat* format = aHasAlpha ? &mARGBFormat : &mXRGBFormat;
   return format->mIsSupported ? format : nullptr;
 }
@@ -161,17 +158,16 @@ static void dmabuf_modifiers(void* data,
 static void dmabuf_format(void* data,
                           struct zwp_linux_dmabuf_v1* zwp_linux_dmabuf,
                           uint32_t format) {
   // XXX: deprecated
 }
 
 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,
                                     uint32_t version) {
   auto display = reinterpret_cast<nsWaylandDisplay*>(data);
   if (!display) return;
 
   if (strcmp(interface, "wl_shm") == 0) {
@@ -200,25 +196,22 @@ static void global_registry_handler(void
                        display->GetEventQueue());
     display->SetPrimarySelectionDeviceManager(primary_selection_device_manager);
   } else if (strcmp(interface, "wl_subcompositor") == 0) {
     auto subcompositor = static_cast<wl_subcompositor*>(
         wl_registry_bind(registry, id, &wl_subcompositor_interface, 1));
     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<zwp_linux_dmabuf_v1*>(
         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,
                                     uint32_t id) {}
 
 static const struct wl_registry_listener registry_listener = {
     global_registry_handler, global_registry_remover};
 
@@ -226,17 +219,16 @@ bool nsWaylandDisplay::DispatchEventQueu
   wl_display_dispatch_queue_pending(mDisplay, mEventQueue);
   return true;
 }
 
 bool nsWaylandDisplay::Matches(wl_display* aDisplay) {
   return mThreadId == PR_GetCurrentThread() && aDisplay == mDisplay;
 }
 
-#ifdef HAVE_LIBDRM
 bool nsWaylandDisplay::ConfigureGbm() {
   if (!nsGbmLib::IsAvailable()) {
     return false;
   }
 
   // TODO - Better DRM device detection/configuration.
   const char* drm_render_node = getenv("MOZ_WAYLAND_DRM_DEVICE");
   if (!drm_render_node) {
@@ -274,50 +266,43 @@ gbm_device* nsWaylandDisplay::GetGbmDevi
 
 int nsWaylandDisplay::GetGbmDeviceFd() {
   if (!mGdmConfigured) {
     ConfigureGbm();
     mGdmConfigured = true;
   }
   return mGbmFd;
 }
-#endif
 
 nsWaylandDisplay::nsWaylandDisplay(wl_display* aDisplay)
     : mDispatcherThreadLoop(nullptr),
       mThreadId(PR_GetCurrentThread()),
       mDisplay(aDisplay),
       mEventQueue(nullptr),
       mDataDeviceManager(nullptr),
       mSubcompositor(nullptr),
       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, &registry_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);
     wl_display_roundtrip(mDisplay);
   } else {
     mDispatcherThreadLoop = MessageLoop::current();
     mEventQueue = wl_display_create_queue(mDisplay);
     wl_proxy_set_queue((struct wl_proxy*)mRegistry, mEventQueue);
@@ -336,17 +321,16 @@ nsWaylandDisplay::~nsWaylandDisplay() {
   mRegistry = nullptr;
 
   if (mEventQueue) {
     wl_event_queue_destroy(mEventQueue);
     mEventQueue = nullptr;
   }
 }
 
-#ifdef HAVE_LIBDRM
 void* nsGbmLib::sGbmLibHandle = nullptr;
 void* nsGbmLib::sXf86DrmLibHandle = nullptr;
 bool nsGbmLib::sLibLoaded = false;
 CreateDeviceFunc nsGbmLib::sCreateDevice;
 CreateFunc nsGbmLib::sCreate;
 CreateWithModifiersFunc nsGbmLib::sCreateWithModifiers;
 GetModifierFunc nsGbmLib::sGetModifier;
 GetStrideFunc nsGbmLib::sGetStride;
@@ -417,12 +401,11 @@ bool nsGbmLib::Load() {
                        DRMLIB_NAME)
                        .get());
       }
     }
   }
 
   return sGbmLibHandle;
 }
-#endif
 
 }  // namespace widget
 }  // namespace mozilla
--- a/widget/gtk/nsWaylandDisplay.h
+++ b/widget/gtk/nsWaylandDisplay.h
@@ -10,22 +10,20 @@
 
 #include "mozilla/widget/mozwayland.h"
 #include "mozilla/widget/gtk-primary-selection-client-protocol.h"
 
 #include "base/message_loop.h"  // for MessageLoop
 #include "base/task.h"          // for NewRunnableMethod, etc
 #include "mozilla/StaticMutex.h"
 
-#ifdef HAVE_LIBDRM
-#  include <drm/drm_fourcc.h>
-#  include <xf86drm.h>
-#  include <gbm.h>
-#  include "mozilla/widget/linux-dmabuf-unstable-v1-client-protocol.h"
-#endif
+#include <drm/drm_fourcc.h>
+#include <xf86drm.h>
+#include <gbm.h>
+#include "mozilla/widget/linux-dmabuf-unstable-v1-client-protocol.h"
 
 namespace mozilla {
 namespace widget {
 
 struct GbmFormat {
   bool mIsSupported;
   bool mHasAlpha;
   int mFormat;
@@ -60,62 +58,55 @@ class nsWaylandDisplay {
   void SetSubcompositor(wl_subcompositor* aSubcompositor);
   void SetDataDeviceManager(wl_data_device_manager* aDataDeviceManager);
   void SetSeat(wl_seat* aSeat);
   void SetPrimarySelectionDeviceManager(
       gtk_primary_selection_device_manager* aPrimarySelectionDeviceManager);
 
   void Shutdown();
 
-#ifdef HAVE_LIBDRM
   void SetDmabuf(zwp_linux_dmabuf_v1* aDmabuf);
   zwp_linux_dmabuf_v1* GetDmabuf() { return mDmabuf; };
   gbm_device* GetGbmDevice();
   // Returns -1 if we fails to gbm device file descriptor.
   int GetGbmDeviceFd();
   bool IsExplicitSyncEnabled() { return mExplicitSync; }
   GbmFormat* GetGbmFormat(bool aHasAlpha);
   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;
   wl_display* mDisplay;
   wl_event_queue* mEventQueue;
   wl_data_device_manager* mDataDeviceManager;
   wl_subcompositor* mSubcompositor;
   wl_seat* mSeat;
   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;
   GbmFormat mXRGBFormat;
   GbmFormat mARGBFormat;
   bool mGdmConfigured;
   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);
 typedef struct gbm_bo* (*CreateFunc)(struct gbm_device*, uint32_t, uint32_t,
                                      uint32_t, uint32_t);
 typedef struct gbm_bo* (*CreateWithModifiersFunc)(struct gbm_device*, uint32_t,
                                                   uint32_t, uint32_t,
                                                   const uint64_t*,
@@ -194,14 +185,13 @@ class nsGbmLib {
   static GetStrideForPlaneFunc sGetStrideForPlane;
   static GetOffsetFunc sGetOffset;
   static DrmPrimeHandleToFDFunc sDrmPrimeHandleToFD;
 
   static void* sGbmLibHandle;
   static void* sXf86DrmLibHandle;
   static bool sLibLoaded;
 };
-#endif
 
 }  // namespace widget
 }  // namespace mozilla
 
 #endif  // __MOZ_WAYLAND_DISPLAY_H__