diff --git a/toolkit/moz.configure b/toolkit/moz.configure index 82203d26a873..82b5a59acf42 100644 --- a/toolkit/moz.configure +++ b/toolkit/moz.configure @@ -250,7 +250,7 @@ add_old_configure_assignment('MOZ_X11', True, when=toolkit_gtk) # Wayland support # ============================================================== wayland_headers = pkg_check_modules( - 'MOZ_WAYLAND', 'gtk+-wayland-3.0 >= 3.10 xkbcommon >= 0.4.1 libdrm > 2.4', + 'MOZ_WAYLAND', 'gtk+-wayland-3.0 >= 3.10 xkbcommon >= 0.4.1', allow_missing=depends(full_toolkit)(lambda t: t == 'cairo-gtk3'), when=depends(full_toolkit)(lambda t: t in ('cairo-gtk3', 'cairo-gtk3-wayland'))) diff --git a/widget/gtk/WaylandDMABufSurface.cpp b/widget/gtk/WaylandDMABufSurface.cpp index d9128c3e7529..7345e0cfce55 100644 --- a/widget/gtk/WaylandDMABufSurface.cpp +++ b/widget/gtk/WaylandDMABufSurface.cpp @@ -20,7 +20,7 @@ #include #include -#include "mozilla/widget/gbm.h" +#include using namespace mozilla; using namespace mozilla::widget; @@ -122,6 +122,7 @@ bool WaylandDMABufSurface::Create(int aWidth, int aHeight, bool aHasAlpha) { return false; } +#ifdef HAVE_GBM_MODIFIERS if (nsGbmLib::IsModifierAvailable() && mGmbFormat->mModifiersCount > 0) { mGbmBufferObject = nsGbmLib::CreateWithModifiers( display->GetGbmDevice(), mWidth, mHeight, mGmbFormat->mFormat, @@ -130,6 +131,7 @@ bool WaylandDMABufSurface::Create(int aWidth, int aHeight, bool aHasAlpha) { mBufferModifier = nsGbmLib::GetModifier(mGbmBufferObject); } } +#endif if (!mGbmBufferObject) { mGbmBufferObject = @@ -141,6 +143,7 @@ bool WaylandDMABufSurface::Create(int aWidth, int aHeight, bool aHasAlpha) { return false; } +#ifdef HAVE_GBM_MODIFIERS if (nsGbmLib::IsModifierAvailable() && display->GetGbmDeviceFd() != -1) { mBufferPlaneCount = nsGbmLib::GetPlaneCount(mGbmBufferObject); for (int i = 0; i < mBufferPlaneCount; i++) { @@ -154,7 +157,9 @@ bool WaylandDMABufSurface::Create(int aWidth, int aHeight, bool aHasAlpha) { mStrides[i] = nsGbmLib::GetStrideForPlane(mGbmBufferObject, i); mOffsets[i] = nsGbmLib::GetOffset(mGbmBufferObject, i); } - } else { + } else +#endif + { mBufferPlaneCount = 1; mStrides[0] = nsGbmLib::GetStride(mGbmBufferObject); mDmabufFds[0] = nsGbmLib::GetFd(mGbmBufferObject); diff --git a/widget/gtk/WindowSurfaceWayland.cpp b/widget/gtk/WindowSurfaceWayland.cpp index 5c877b83558c..58a48e8724d4 100644 --- a/widget/gtk/WindowSurfaceWayland.cpp +++ b/widget/gtk/WindowSurfaceWayland.cpp @@ -415,6 +415,7 @@ already_AddRefed WindowBackBufferShm::Lock() { BUFFER_BPP * mWidth, GetSurfaceFormat()); } +#ifdef HAVE_LIBDRM WindowBackBufferDMABuf::WindowBackBufferDMABuf( nsWaylandDisplay* aWaylandDisplay, int aWidth, int aHeight) : WindowBackBuffer(aWaylandDisplay) { @@ -477,6 +478,7 @@ 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) { @@ -532,10 +534,12 @@ 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; @@ -543,6 +547,7 @@ bool WindowSurfaceWayland::UseDMABufBackend() { WindowBackBuffer* WindowSurfaceWayland::CreateWaylandBuffer(int aWidth, int aHeight) { +#ifdef HAVE_LIBDRM if (UseDMABufBackend()) { static bool sDMABufBufferCreated = false; WindowBackBuffer* buffer = @@ -562,6 +567,7 @@ 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 26766695205a..b6a5b7dd1b41 100644 --- a/widget/gtk/WindowSurfaceWayland.h +++ b/widget/gtk/WindowSurfaceWayland.h @@ -10,7 +10,9 @@ #include #include "mozilla/gfx/Types.h" #include "nsWaylandDisplay.h" -#include "WaylandDMABufSurface.h" +#ifdef HAVE_LIBDRM +# include "WaylandDMABufSurface.h" +#endif #define BACK_BUFFER_NUM 2 @@ -119,6 +121,7 @@ class WindowBackBufferShm : public WindowBackBuffer { bool mIsLocked; }; +#ifdef HAVE_LIBDRM class WindowBackBufferDMABuf : public WindowBackBuffer { public: WindowBackBufferDMABuf(nsWaylandDisplay* aWaylandDisplay, int aWidth, @@ -145,6 +148,7 @@ class WindowBackBufferDMABuf : public WindowBackBuffer { private: WaylandDMABufSurface mDMAbufSurface; }; +#endif class WindowImageSurface { public: diff --git a/widget/gtk/moz.build b/widget/gtk/moz.build index 8fc27c1db6ca..cb9ac2c8a2fc 100644 --- a/widget/gtk/moz.build +++ b/widget/gtk/moz.build @@ -99,11 +99,17 @@ 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/nsGtkKeyUtils.cpp b/widget/gtk/nsGtkKeyUtils.cpp index 9e5ad11181f5..8b448692de0c 100644 --- a/widget/gtk/nsGtkKeyUtils.cpp +++ b/widget/gtk/nsGtkKeyUtils.cpp @@ -13,7 +13,6 @@ #include #include #include -#include #ifdef MOZ_WIDGET_GTK # include #endif diff --git a/widget/gtk/nsWaylandDisplay.cpp b/widget/gtk/nsWaylandDisplay.cpp index 2c934b73384f..50586ff2c23f 100644 --- a/widget/gtk/nsWaylandDisplay.cpp +++ b/widget/gtk/nsWaylandDisplay.cpp @@ -13,8 +13,10 @@ 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) @@ -114,6 +116,7 @@ void nsWaylandDisplay::SetPrimarySelectionDeviceManager( mPrimarySelectionDeviceManager = aPrimarySelectionDeviceManager; } +#ifdef HAVE_LIBDRM void nsWaylandDisplay::SetDmabuf(zwp_linux_dmabuf_v1* aDmabuf) { mDmabuf = aDmabuf; } @@ -163,6 +166,7 @@ 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, @@ -201,12 +205,15 @@ static void global_registry_handler(void* data, wl_registry* registry, wl_proxy_set_queue((struct wl_proxy*)subcompositor, display->GetEventQueue()); display->SetSubcompositor(subcompositor); - } else if (strcmp(interface, "zwp_linux_dmabuf_v1") == 0 && version > 2) { + } +#ifdef HAVE_LIBDRM + 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, @@ -224,6 +231,7 @@ bool nsWaylandDisplay::Matches(wl_display* aDisplay) { return mThreadId == PR_GetCurrentThread() && aDisplay == mDisplay; } +#ifdef HAVE_LIBDRM bool nsWaylandDisplay::ConfigureGbm() { if (!nsGbmLib::IsAvailable()) { return false; @@ -271,6 +279,7 @@ int nsWaylandDisplay::GetGbmDeviceFd() { } return mGbmFd; } +#endif nsWaylandDisplay::nsWaylandDisplay(wl_display* aDisplay) : mDispatcherThreadLoop(nullptr), @@ -282,22 +291,28 @@ nsWaylandDisplay::nsWaylandDisplay(wl_display* aDisplay) mSeat(nullptr), mShm(nullptr), mPrimarySelectionDeviceManager(nullptr), - mRegistry(nullptr), + mRegistry(nullptr) +#ifdef HAVE_LIBDRM + , mGbmDevice(nullptr), mGbmFd(-1), mXRGBFormat({false, false, -1, nullptr, 0}), mARGBFormat({false, false, -1, nullptr, 0}), mGdmConfigured(false), - mExplicitSync(false) { + mExplicitSync(false) +#endif +{ 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); @@ -326,6 +341,7 @@ nsWaylandDisplay::~nsWaylandDisplay() { } } +#ifdef HAVE_LIBDRM void* nsGbmLib::sGbmLibHandle = nullptr; void* nsGbmLib::sXf86DrmLibHandle = nullptr; bool nsGbmLib::sLibLoaded = false; @@ -406,6 +422,7 @@ bool nsGbmLib::Load() { return sGbmLibHandle; } +#endif } // namespace widget } // namespace mozilla diff --git a/widget/gtk/nsWaylandDisplay.h b/widget/gtk/nsWaylandDisplay.h index 3c4b3738f00d..ac97cf7c1c53 100644 --- a/widget/gtk/nsWaylandDisplay.h +++ b/widget/gtk/nsWaylandDisplay.h @@ -15,10 +15,12 @@ #include "base/task.h" // for NewRunnableMethod, etc #include "mozilla/StaticMutex.h" -#include -#include -#include "mozilla/widget/gbm.h" -#include "mozilla/widget/linux-dmabuf-unstable-v1-client-protocol.h" +#ifdef HAVE_LIBDRM +# include +# include +# include +# include "mozilla/widget/linux-dmabuf-unstable-v1-client-protocol.h" +#endif namespace mozilla { namespace widget { @@ -63,6 +65,7 @@ class nsWaylandDisplay { void Shutdown(); +#ifdef HAVE_LIBDRM void SetDmabuf(zwp_linux_dmabuf_v1* aDmabuf); zwp_linux_dmabuf_v1* GetDmabuf() { return mDmabuf; }; gbm_device* GetGbmDevice(); @@ -73,9 +76,12 @@ 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; @@ -87,6 +93,7 @@ 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; @@ -96,12 +103,14 @@ 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); @@ -190,6 +199,7 @@ class nsGbmLib { static void* sXf86DrmLibHandle; static bool sLibLoaded; }; +#endif } // namespace widget } // namespace mozilla diff --git a/widget/gtk/wayland/gbm.h b/widget/gtk/wayland/gbm.h deleted file mode 100644 index bd94fa8967d8..000000000000 --- a/widget/gtk/wayland/gbm.h +++ /dev/null @@ -1,480 +0,0 @@ -/* - * Copyright © 2011 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Authors: - * Benjamin Franzke - */ - -#ifndef _GBM_H_ -#define _GBM_H_ - -#define __GBM__ 1 - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \file gbm.h - * \brief Generic Buffer Manager - */ - -struct gbm_device; -struct gbm_bo; -struct gbm_surface; - -/** - * \mainpage The Generic Buffer Manager - * - * This module provides an abstraction that the caller can use to request a - * buffer from the underlying memory management system for the platform. - * - * This allows the creation of portable code whilst still allowing access to - * the underlying memory manager. - */ - -/** - * Abstraction representing the handle to a buffer allocated by the - * manager - */ -union gbm_bo_handle { - void* ptr; - int32_t s32; - uint32_t u32; - int64_t s64; - uint64_t u64; -}; - -/** Format of the allocated buffer */ -enum gbm_bo_format { - /** RGB with 8 bits per channel in a 32 bit value */ - GBM_BO_FORMAT_XRGB8888, - /** ARGB with 8 bits per channel in a 32 bit value */ - GBM_BO_FORMAT_ARGB8888 -}; - -/** - * The FourCC format codes are taken from the drm_fourcc.h definition, and - * re-namespaced. New GBM formats must not be added, unless they are - * identical ports from drm_fourcc. - */ -#define __gbm_fourcc_code(a, b, c, d) \ - ((uint32_t)(a) | ((uint32_t)(b) << 8) | ((uint32_t)(c) << 16) | \ - ((uint32_t)(d) << 24)) - -#define GBM_FORMAT_BIG_ENDIAN \ - (1 << 31) /* format is big endian instead of little endian */ - -/* color index */ -#define GBM_FORMAT_C8 __gbm_fourcc_code('C', '8', ' ', ' ') /* [7:0] C */ - -/* 8 bpp Red */ -#define GBM_FORMAT_R8 __gbm_fourcc_code('R', '8', ' ', ' ') /* [7:0] R */ - -/* 16 bpp RG */ -#define GBM_FORMAT_GR88 \ - __gbm_fourcc_code('G', 'R', '8', '8') /* [15:0] G:R 8:8 little endian */ - -/* 8 bpp RGB */ -#define GBM_FORMAT_RGB332 \ - __gbm_fourcc_code('R', 'G', 'B', '8') /* [7:0] R:G:B 3:3:2 */ -#define GBM_FORMAT_BGR233 \ - __gbm_fourcc_code('B', 'G', 'R', '8') /* [7:0] B:G:R 2:3:3 */ - -/* 16 bpp RGB */ -#define GBM_FORMAT_XRGB4444 \ - __gbm_fourcc_code('X', 'R', '1', \ - '2') /* [15:0] x:R:G:B 4:4:4:4 little endian */ -#define GBM_FORMAT_XBGR4444 \ - __gbm_fourcc_code('X', 'B', '1', \ - '2') /* [15:0] x:B:G:R 4:4:4:4 little endian */ -#define GBM_FORMAT_RGBX4444 \ - __gbm_fourcc_code('R', 'X', '1', \ - '2') /* [15:0] R:G:B:x 4:4:4:4 little endian */ -#define GBM_FORMAT_BGRX4444 \ - __gbm_fourcc_code('B', 'X', '1', \ - '2') /* [15:0] B:G:R:x 4:4:4:4 little endian */ - -#define GBM_FORMAT_ARGB4444 \ - __gbm_fourcc_code('A', 'R', '1', \ - '2') /* [15:0] A:R:G:B 4:4:4:4 little endian */ -#define GBM_FORMAT_ABGR4444 \ - __gbm_fourcc_code('A', 'B', '1', \ - '2') /* [15:0] A:B:G:R 4:4:4:4 little endian */ -#define GBM_FORMAT_RGBA4444 \ - __gbm_fourcc_code('R', 'A', '1', \ - '2') /* [15:0] R:G:B:A 4:4:4:4 little endian */ -#define GBM_FORMAT_BGRA4444 \ - __gbm_fourcc_code('B', 'A', '1', \ - '2') /* [15:0] B:G:R:A 4:4:4:4 little endian */ - -#define GBM_FORMAT_XRGB1555 \ - __gbm_fourcc_code('X', 'R', '1', \ - '5') /* [15:0] x:R:G:B 1:5:5:5 little endian */ -#define GBM_FORMAT_XBGR1555 \ - __gbm_fourcc_code('X', 'B', '1', \ - '5') /* [15:0] x:B:G:R 1:5:5:5 little endian */ -#define GBM_FORMAT_RGBX5551 \ - __gbm_fourcc_code('R', 'X', '1', \ - '5') /* [15:0] R:G:B:x 5:5:5:1 little endian */ -#define GBM_FORMAT_BGRX5551 \ - __gbm_fourcc_code('B', 'X', '1', \ - '5') /* [15:0] B:G:R:x 5:5:5:1 little endian */ - -#define GBM_FORMAT_ARGB1555 \ - __gbm_fourcc_code('A', 'R', '1', \ - '5') /* [15:0] A:R:G:B 1:5:5:5 little endian */ -#define GBM_FORMAT_ABGR1555 \ - __gbm_fourcc_code('A', 'B', '1', \ - '5') /* [15:0] A:B:G:R 1:5:5:5 little endian */ -#define GBM_FORMAT_RGBA5551 \ - __gbm_fourcc_code('R', 'A', '1', \ - '5') /* [15:0] R:G:B:A 5:5:5:1 little endian */ -#define GBM_FORMAT_BGRA5551 \ - __gbm_fourcc_code('B', 'A', '1', \ - '5') /* [15:0] B:G:R:A 5:5:5:1 little endian */ - -#define GBM_FORMAT_RGB565 \ - __gbm_fourcc_code('R', 'G', '1', '6') /* [15:0] R:G:B 5:6:5 little endian */ -#define GBM_FORMAT_BGR565 \ - __gbm_fourcc_code('B', 'G', '1', '6') /* [15:0] B:G:R 5:6:5 little endian */ - -/* 24 bpp RGB */ -#define GBM_FORMAT_RGB888 \ - __gbm_fourcc_code('R', 'G', '2', '4') /* [23:0] R:G:B little endian */ -#define GBM_FORMAT_BGR888 \ - __gbm_fourcc_code('B', 'G', '2', '4') /* [23:0] B:G:R little endian */ - -/* 32 bpp RGB */ -#define GBM_FORMAT_XRGB8888 \ - __gbm_fourcc_code('X', 'R', '2', \ - '4') /* [31:0] x:R:G:B 8:8:8:8 little endian */ -#define GBM_FORMAT_XBGR8888 \ - __gbm_fourcc_code('X', 'B', '2', \ - '4') /* [31:0] x:B:G:R 8:8:8:8 little endian */ -#define GBM_FORMAT_RGBX8888 \ - __gbm_fourcc_code('R', 'X', '2', \ - '4') /* [31:0] R:G:B:x 8:8:8:8 little endian */ -#define GBM_FORMAT_BGRX8888 \ - __gbm_fourcc_code('B', 'X', '2', \ - '4') /* [31:0] B:G:R:x 8:8:8:8 little endian */ - -#define GBM_FORMAT_ARGB8888 \ - __gbm_fourcc_code('A', 'R', '2', \ - '4') /* [31:0] A:R:G:B 8:8:8:8 little endian */ -#define GBM_FORMAT_ABGR8888 \ - __gbm_fourcc_code('A', 'B', '2', \ - '4') /* [31:0] A:B:G:R 8:8:8:8 little endian */ -#define GBM_FORMAT_RGBA8888 \ - __gbm_fourcc_code('R', 'A', '2', \ - '4') /* [31:0] R:G:B:A 8:8:8:8 little endian */ -#define GBM_FORMAT_BGRA8888 \ - __gbm_fourcc_code('B', 'A', '2', \ - '4') /* [31:0] B:G:R:A 8:8:8:8 little endian */ - -#define GBM_FORMAT_XRGB2101010 \ - __gbm_fourcc_code('X', 'R', '3', \ - '0') /* [31:0] x:R:G:B 2:10:10:10 little endian */ -#define GBM_FORMAT_XBGR2101010 \ - __gbm_fourcc_code('X', 'B', '3', \ - '0') /* [31:0] x:B:G:R 2:10:10:10 little endian */ -#define GBM_FORMAT_RGBX1010102 \ - __gbm_fourcc_code('R', 'X', '3', \ - '0') /* [31:0] R:G:B:x 10:10:10:2 little endian */ -#define GBM_FORMAT_BGRX1010102 \ - __gbm_fourcc_code('B', 'X', '3', \ - '0') /* [31:0] B:G:R:x 10:10:10:2 little endian */ - -#define GBM_FORMAT_ARGB2101010 \ - __gbm_fourcc_code('A', 'R', '3', \ - '0') /* [31:0] A:R:G:B 2:10:10:10 little endian */ -#define GBM_FORMAT_ABGR2101010 \ - __gbm_fourcc_code('A', 'B', '3', \ - '0') /* [31:0] A:B:G:R 2:10:10:10 little endian */ -#define GBM_FORMAT_RGBA1010102 \ - __gbm_fourcc_code('R', 'A', '3', \ - '0') /* [31:0] R:G:B:A 10:10:10:2 little endian */ -#define GBM_FORMAT_BGRA1010102 \ - __gbm_fourcc_code('B', 'A', '3', \ - '0') /* [31:0] B:G:R:A 10:10:10:2 little endian */ - -/* packed YCbCr */ -#define GBM_FORMAT_YUYV \ - __gbm_fourcc_code('Y', 'U', 'Y', \ - 'V') /* [31:0] Cr0:Y1:Cb0:Y0 8:8:8:8 little endian */ -#define GBM_FORMAT_YVYU \ - __gbm_fourcc_code('Y', 'V', 'Y', \ - 'U') /* [31:0] Cb0:Y1:Cr0:Y0 8:8:8:8 little endian */ -#define GBM_FORMAT_UYVY \ - __gbm_fourcc_code('U', 'Y', 'V', \ - 'Y') /* [31:0] Y1:Cr0:Y0:Cb0 8:8:8:8 little endian */ -#define GBM_FORMAT_VYUY \ - __gbm_fourcc_code('V', 'Y', 'U', \ - 'Y') /* [31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian */ - -#define GBM_FORMAT_AYUV \ - __gbm_fourcc_code('A', 'Y', 'U', \ - 'V') /* [31:0] A:Y:Cb:Cr 8:8:8:8 little endian */ - -/* - * 2 plane YCbCr - * index 0 = Y plane, [7:0] Y - * index 1 = Cr:Cb plane, [15:0] Cr:Cb little endian - * or - * index 1 = Cb:Cr plane, [15:0] Cb:Cr little endian - */ -#define GBM_FORMAT_NV12 \ - __gbm_fourcc_code('N', 'V', '1', '2') /* 2x2 subsampled Cr:Cb plane */ -#define GBM_FORMAT_NV21 \ - __gbm_fourcc_code('N', 'V', '2', '1') /* 2x2 subsampled Cb:Cr plane */ -#define GBM_FORMAT_NV16 \ - __gbm_fourcc_code('N', 'V', '1', '6') /* 2x1 subsampled Cr:Cb plane */ -#define GBM_FORMAT_NV61 \ - __gbm_fourcc_code('N', 'V', '6', '1') /* 2x1 subsampled Cb:Cr plane */ - -/* - * 3 plane YCbCr - * index 0: Y plane, [7:0] Y - * index 1: Cb plane, [7:0] Cb - * index 2: Cr plane, [7:0] Cr - * or - * index 1: Cr plane, [7:0] Cr - * index 2: Cb plane, [7:0] Cb - */ -#define GBM_FORMAT_YUV410 \ - __gbm_fourcc_code('Y', 'U', 'V', \ - '9') /* 4x4 subsampled Cb (1) and Cr (2) planes */ -#define GBM_FORMAT_YVU410 \ - __gbm_fourcc_code('Y', 'V', 'U', \ - '9') /* 4x4 subsampled Cr (1) and Cb (2) planes */ -#define GBM_FORMAT_YUV411 \ - __gbm_fourcc_code('Y', 'U', '1', \ - '1') /* 4x1 subsampled Cb (1) and Cr (2) planes */ -#define GBM_FORMAT_YVU411 \ - __gbm_fourcc_code('Y', 'V', '1', \ - '1') /* 4x1 subsampled Cr (1) and Cb (2) planes */ -#define GBM_FORMAT_YUV420 \ - __gbm_fourcc_code('Y', 'U', '1', \ - '2') /* 2x2 subsampled Cb (1) and Cr (2) planes */ -#define GBM_FORMAT_YVU420 \ - __gbm_fourcc_code('Y', 'V', '1', \ - '2') /* 2x2 subsampled Cr (1) and Cb (2) planes */ -#define GBM_FORMAT_YUV422 \ - __gbm_fourcc_code('Y', 'U', '1', \ - '6') /* 2x1 subsampled Cb (1) and Cr (2) planes */ -#define GBM_FORMAT_YVU422 \ - __gbm_fourcc_code('Y', 'V', '1', \ - '6') /* 2x1 subsampled Cr (1) and Cb (2) planes */ -#define GBM_FORMAT_YUV444 \ - __gbm_fourcc_code('Y', 'U', '2', \ - '4') /* non-subsampled Cb (1) and Cr (2) planes */ -#define GBM_FORMAT_YVU444 \ - __gbm_fourcc_code('Y', 'V', '2', \ - '4') /* non-subsampled Cr (1) and Cb (2) planes */ - -struct gbm_format_name_desc { - char name[5]; -}; - -/** - * Flags to indicate the intended use for the buffer - these are passed into - * gbm_bo_create(). The caller must set the union of all the flags that are - * appropriate - * - * \sa Use gbm_device_is_format_supported() to check if the combination of - * format and use flags are supported - */ -enum gbm_bo_flags { - /** - * Buffer is going to be presented to the screen using an API such as KMS - */ - GBM_BO_USE_SCANOUT = (1 << 0), - /** - * Buffer is going to be used as cursor - */ - GBM_BO_USE_CURSOR = (1 << 1), - /** - * Deprecated - */ - GBM_BO_USE_CURSOR_64X64 = GBM_BO_USE_CURSOR, - /** - * Buffer is to be used for rendering - for example it is going to be used - * as the storage for a color buffer - */ - GBM_BO_USE_RENDERING = (1 << 2), - /** - * Buffer can be used for gbm_bo_write. This is guaranteed to work - * with GBM_BO_USE_CURSOR, but may not work for other combinations. - */ - GBM_BO_USE_WRITE = (1 << 3), - /** - * Buffer is linear, i.e. not tiled. - */ - GBM_BO_USE_LINEAR = (1 << 4), -}; - -int gbm_device_get_fd(struct gbm_device* gbm); - -const char* gbm_device_get_backend_name(struct gbm_device* gbm); - -int gbm_device_is_format_supported(struct gbm_device* gbm, uint32_t format, - uint32_t usage); - -int gbm_device_get_format_modifier_plane_count(struct gbm_device* gbm, - uint32_t format, - uint64_t modifier); - -void gbm_device_destroy(struct gbm_device* gbm); - -struct gbm_device* gbm_create_device(int fd); - -struct gbm_bo* gbm_bo_create(struct gbm_device* gbm, uint32_t width, - uint32_t height, uint32_t format, uint32_t flags); - -struct gbm_bo* gbm_bo_create_with_modifiers(struct gbm_device* gbm, - uint32_t width, uint32_t height, - uint32_t format, - const uint64_t* modifiers, - const unsigned int count); -#define GBM_BO_IMPORT_WL_BUFFER 0x5501 -#define GBM_BO_IMPORT_EGL_IMAGE 0x5502 -#define GBM_BO_IMPORT_FD 0x5503 -#define GBM_BO_IMPORT_FD_MODIFIER 0x5504 - -struct gbm_import_fd_data { - int fd; - uint32_t width; - uint32_t height; - uint32_t stride; - uint32_t format; -}; - -struct gbm_import_fd_modifier_data { - uint32_t width; - uint32_t height; - uint32_t format; - uint32_t num_fds; - int fds[4]; - int strides[4]; - int offsets[4]; - uint64_t modifier; -}; - -struct gbm_bo* gbm_bo_import(struct gbm_device* gbm, uint32_t type, - void* buffer, uint32_t usage); - -/** - * Flags to indicate the type of mapping for the buffer - these are - * passed into gbm_bo_map(). The caller must set the union of all the - * flags that are appropriate. - * - * These flags are independent of the GBM_BO_USE_* creation flags. However, - * mapping the buffer may require copying to/from a staging buffer. - * - * See also: pipe_transfer_usage - */ -enum gbm_bo_transfer_flags { - /** - * Buffer contents read back (or accessed directly) at transfer - * create time. - */ - GBM_BO_TRANSFER_READ = (1 << 0), - /** - * Buffer contents will be written back at unmap time - * (or modified as a result of being accessed directly). - */ - GBM_BO_TRANSFER_WRITE = (1 << 1), - /** - * Read/modify/write - */ - GBM_BO_TRANSFER_READ_WRITE = (GBM_BO_TRANSFER_READ | GBM_BO_TRANSFER_WRITE), -}; - -void* gbm_bo_map(struct gbm_bo* bo, uint32_t x, uint32_t y, uint32_t width, - uint32_t height, uint32_t flags, uint32_t* stride, - void** map_data); - -void gbm_bo_unmap(struct gbm_bo* bo, void* map_data); - -uint32_t gbm_bo_get_width(struct gbm_bo* bo); - -uint32_t gbm_bo_get_height(struct gbm_bo* bo); - -uint32_t gbm_bo_get_stride(struct gbm_bo* bo); - -uint32_t gbm_bo_get_stride_for_plane(struct gbm_bo* bo, int plane); - -uint32_t gbm_bo_get_format(struct gbm_bo* bo); - -uint32_t gbm_bo_get_bpp(struct gbm_bo* bo); - -uint32_t gbm_bo_get_offset(struct gbm_bo* bo, int plane); - -struct gbm_device* gbm_bo_get_device(struct gbm_bo* bo); - -union gbm_bo_handle gbm_bo_get_handle(struct gbm_bo* bo); - -int gbm_bo_get_fd(struct gbm_bo* bo); - -uint64_t gbm_bo_get_modifier(struct gbm_bo* bo); - -int gbm_bo_get_plane_count(struct gbm_bo* bo); - -union gbm_bo_handle gbm_bo_get_handle_for_plane(struct gbm_bo* bo, int plane); - -int gbm_bo_write(struct gbm_bo* bo, const void* buf, size_t count); - -void gbm_bo_set_user_data(struct gbm_bo* bo, void* data, - void (*destroy_user_data)(struct gbm_bo*, void*)); - -void* gbm_bo_get_user_data(struct gbm_bo* bo); - -void gbm_bo_destroy(struct gbm_bo* bo); - -struct gbm_surface* gbm_surface_create(struct gbm_device* gbm, uint32_t width, - uint32_t height, uint32_t format, - uint32_t flags); - -struct gbm_surface* gbm_surface_create_with_modifiers( - struct gbm_device* gbm, uint32_t width, uint32_t height, uint32_t format, - const uint64_t* modifiers, const unsigned int count); - -struct gbm_bo* gbm_surface_lock_front_buffer(struct gbm_surface* surface); - -void gbm_surface_release_buffer(struct gbm_surface* surface, struct gbm_bo* bo); - -int gbm_surface_has_free_buffers(struct gbm_surface* surface); - -void gbm_surface_destroy(struct gbm_surface* surface); - -char* gbm_format_get_name(uint32_t gbm_format, - struct gbm_format_name_desc* desc); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/widget/gtk/wayland/moz.build b/widget/gtk/wayland/moz.build index 2168eae1c673..cc026db4edbe 100644 --- a/widget/gtk/wayland/moz.build +++ b/widget/gtk/wayland/moz.build @@ -13,7 +13,6 @@ SOURCES += [ ] EXPORTS.mozilla.widget += [ - 'gbm.h', 'gtk-primary-selection-client-protocol.h', 'linux-dmabuf-unstable-v1-client-protocol.h', ]