diff --git a/gfx/thebes/gfxPlatformGtk.cpp b/gfx/thebes/gfxPlatformGtk.cpp index e169f4cc9178..547f5c20342b 100644 --- a/gfx/thebes/gfxPlatformGtk.cpp +++ b/gfx/thebes/gfxPlatformGtk.cpp @@ -733,4 +733,8 @@ bool gfxPlatformGtk::UseWaylandDMABufTextures() { bool gfxPlatformGtk::UseWaylandDMABufWebGL() { return IsWaylandDisplay() && nsWaylandDisplay::IsDMABufWebGLEnabled(); } +bool gfxPlatformGtk::UseWaylandHardwareVideoDecoding() { + return IsWaylandDisplay() && nsWaylandDisplay::IsDMABufVAAPIEnabled() && + gfxPlatform::CanUseHardwareVideoDecoding(); +} #endif diff --git a/gfx/thebes/gfxPlatformGtk.h b/gfx/thebes/gfxPlatformGtk.h index 302053528def..c3e656e11572 100644 --- a/gfx/thebes/gfxPlatformGtk.h +++ b/gfx/thebes/gfxPlatformGtk.h @@ -95,6 +95,7 @@ class gfxPlatformGtk : public gfxPlatform { #ifdef MOZ_WAYLAND bool UseWaylandDMABufTextures(); bool UseWaylandDMABufWebGL(); + bool UseWaylandHardwareVideoDecoding(); #endif bool IsX11Display() { return mIsX11Display; } diff --git a/widget/gtk/nsWaylandDisplay.cpp b/widget/gtk/nsWaylandDisplay.cpp index 7fcc5ba44312..a37270b99e90 100644 --- a/widget/gtk/nsWaylandDisplay.cpp +++ b/widget/gtk/nsWaylandDisplay.cpp @@ -26,6 +26,8 @@ namespace widget { #define DMABUF_BASIC_PREF "widget.wayland_dmabuf_basic_compositor.enabled" // Enable dmabuf for WebGL backend #define DMABUF_WEBGL_PREF "widget.wayland_dmabuf_webgl.enabled" +// Enable dmabuf for VA-API backend +#define DMABUF_VAAPI_PREF "widget.wayland_dmabuf_vaapi.enabled" // See WindowSurfaceWayland::RenderingCacheMode for details. #define CACHE_MODE_PREF "widget.wayland_cache_mode" @@ -33,6 +35,7 @@ bool nsWaylandDisplay::sIsDMABufEnabled = false; int nsWaylandDisplay::sIsDMABufPrefTextState = false; int nsWaylandDisplay::sIsDMABufPrefBasicCompositorState = false; int nsWaylandDisplay::sIsDMABufPrefWebGLState = false; +int nsWaylandDisplay::sIsDMABufPrefVAAPIState = false; bool nsWaylandDisplay::sIsDMABufConfigured = false; int nsWaylandDisplay::sRenderingCacheModePref = -1; bool nsWaylandDisplay::sIsPrefLoaded = false; @@ -423,6 +426,7 @@ nsWaylandDisplay::nsWaylandDisplay(wl_display* aDisplay) sIsDMABufPrefBasicCompositorState = Preferences::GetBool(DMABUF_BASIC_PREF, false); sIsDMABufPrefWebGLState = Preferences::GetBool(DMABUF_WEBGL_PREF, false); + sIsDMABufPrefVAAPIState = Preferences::GetBool(DMABUF_VAAPI_PREF, false); sRenderingCacheModePref = Preferences::GetInt(CACHE_MODE_PREF, 0); sIsPrefLoaded = true; } @@ -505,6 +509,9 @@ bool nsWaylandDisplay::IsDMABufTexturesEnabled() { bool nsWaylandDisplay::IsDMABufWebGLEnabled() { return IsDMABufEnabled() && sIsDMABufPrefWebGLState; } +bool nsWaylandDisplay::IsDMABufVAAPIEnabled() { + return IsDMABufEnabled() && sIsDMABufPrefVAAPIState; +} void* nsGbmLib::sGbmLibHandle = nullptr; void* nsGbmLib::sXf86DrmLibHandle = nullptr; diff --git a/widget/gtk/nsWaylandDisplay.h b/widget/gtk/nsWaylandDisplay.h index 1b9be09adf8e..d56bfed3115f 100644 --- a/widget/gtk/nsWaylandDisplay.h +++ b/widget/gtk/nsWaylandDisplay.h @@ -90,6 +90,7 @@ class nsWaylandDisplay { static bool IsDMABufBasicEnabled(); static bool IsDMABufTexturesEnabled(); static bool IsDMABufWebGLEnabled(); + static bool IsDMABufVAAPIEnabled(); // See WindowSurfaceWayland::CacheMode for details. int GetRenderingCacheModePref() { return sRenderingCacheModePref; }; @@ -121,6 +122,7 @@ class nsWaylandDisplay { static int sIsDMABufPrefTextState; static int sIsDMABufPrefBasicCompositorState; static int sIsDMABufPrefWebGLState; + static int sIsDMABufPrefVAAPIState; static bool sIsDMABufConfigured; static int sRenderingCacheModePref; static bool sIsPrefLoaded;