mirror of
https://github.com/hyprwm/hyprlock.git
synced 2026-05-19 19:28:08 +02:00
cmake: make video backend optional via VIDEO_BACKEND flag
Add VIDEO_BACKEND cmake option (default ON) that controls whether FFmpeg is required and video playback is compiled in. When OFF, VideoBackend.cpp is excluded from the build and all video code paths in Background are gated by HYPRLOCK_HAS_VIDEO, allowing a no-FFmpeg build for packagers who want to ship without the dependency.
This commit is contained in:
parent
cfffe9b704
commit
af51b7c477
3 changed files with 36 additions and 7 deletions
|
|
@ -88,11 +88,15 @@ pkg_check_modules(
|
|||
gbm
|
||||
hyprutils>=0.11.0
|
||||
sdbus-c++>=2.0.0
|
||||
hyprgraphics>=0.1.6
|
||||
libavcodec
|
||||
libavformat
|
||||
libavutil
|
||||
libswscale)
|
||||
hyprgraphics>=0.1.6)
|
||||
|
||||
option(VIDEO_BACKEND "Enable video background support via FFmpeg" ON)
|
||||
if(VIDEO_BACKEND)
|
||||
pkg_check_modules(ffmpeg REQUIRED IMPORTED_TARGET libavcodec libavformat libavutil libswscale)
|
||||
message(STATUS "Video backend: enabled")
|
||||
else()
|
||||
message(STATUS "Video backend: disabled")
|
||||
endif()
|
||||
find_library(PAM_FOUND NAMES pam libpam)
|
||||
if(PAM_FOUND)
|
||||
set(PAM_LIB ${PAM_FOUND})
|
||||
|
|
@ -108,10 +112,20 @@ endif()
|
|||
message(STATUS "Found pam at ${PAM_LIB}")
|
||||
|
||||
file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp")
|
||||
|
||||
if(NOT VIDEO_BACKEND)
|
||||
list(FILTER SRCFILES EXCLUDE REGEX ".*/VideoBackend\\.cpp$")
|
||||
endif()
|
||||
|
||||
add_executable(hyprlock ${SRCFILES})
|
||||
target_link_libraries(hyprlock PRIVATE ${PAM_LIB} rt Threads::Threads PkgConfig::deps
|
||||
OpenGL::EGL OpenGL::GLES3)
|
||||
|
||||
if(VIDEO_BACKEND)
|
||||
target_compile_definitions(hyprlock PRIVATE HYPRLOCK_HAS_VIDEO)
|
||||
target_link_libraries(hyprlock PRIVATE PkgConfig::ffmpeg)
|
||||
endif()
|
||||
|
||||
# protocols
|
||||
pkg_get_variable(WAYLAND_PROTOCOLS_DIR wayland-protocols pkgdatadir)
|
||||
message(STATUS "Found wayland-protocols at ${WAYLAND_PROTOCOLS_DIR}")
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@ void CBackground::configure(const std::unordered_map<std::string, std::any>& pro
|
|||
resourceID = 0;
|
||||
}
|
||||
} else if (!path.empty()) {
|
||||
#ifdef HYPRLOCK_HAS_VIDEO
|
||||
if (CVideoBackend::isVideoFile(path)) {
|
||||
m_videoBackend = makeUnique<CVideoBackend>();
|
||||
if (!m_videoBackend->open(path)) {
|
||||
|
|
@ -96,12 +97,18 @@ void CBackground::configure(const std::unordered_map<std::string, std::any>& pro
|
|||
} else {
|
||||
m_uploadBuffer.resize(4 * m_videoBackend->frameW() * m_videoBackend->frameH());
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
resourceID = g_asyncResourceManager->requestImage(path, m_imageRevision, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
if (!reloadCommand.empty() && reloadTime > -1 && !m_videoBackend) {
|
||||
if (!reloadCommand.empty() && reloadTime > -1
|
||||
#ifdef HYPRLOCK_HAS_VIDEO
|
||||
&& !m_videoBackend
|
||||
#endif
|
||||
) {
|
||||
try {
|
||||
if (!isScreenshot)
|
||||
modificationTime = std::filesystem::last_write_time(absolutePath(path, ""));
|
||||
|
|
@ -112,11 +119,13 @@ void CBackground::configure(const std::unordered_map<std::string, std::any>& pro
|
|||
}
|
||||
|
||||
void CBackground::reset() {
|
||||
#ifdef HYPRLOCK_HAS_VIDEO
|
||||
if (m_videoBackend) {
|
||||
m_videoBackend.reset();
|
||||
m_videoTexture.destroyTexture();
|
||||
m_uploadBuffer.clear();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (reloadTimer) {
|
||||
reloadTimer->cancel();
|
||||
|
|
@ -243,6 +252,7 @@ void CBackground::renderToFB(const CTexture& tex, CFramebuffer& fb, int passes,
|
|||
}
|
||||
|
||||
bool CBackground::draw(const SRenderData& data) {
|
||||
#ifdef HYPRLOCK_HAS_VIDEO
|
||||
// ── Video background fast path ────────────────────────────────────────
|
||||
if (m_videoBackend) {
|
||||
if (m_videoBackend->swapFrame(m_uploadBuffer)) {
|
||||
|
|
@ -286,6 +296,7 @@ bool CBackground::draw(const SRenderData& data) {
|
|||
return true; // always request the next compositor frame
|
||||
}
|
||||
// ── End video path ────────────────────────────────────────────────────
|
||||
#endif
|
||||
|
||||
updatePrimaryAsset();
|
||||
updatePendingAsset();
|
||||
|
|
|
|||
|
|
@ -6,7 +6,9 @@
|
|||
#include "../../helpers/Color.hpp"
|
||||
#include "../../core/Timer.hpp"
|
||||
#include "../Framebuffer.hpp"
|
||||
#ifdef HYPRLOCK_HAS_VIDEO
|
||||
#include "../VideoBackend.hpp"
|
||||
#endif
|
||||
#include <hyprutils/math/Misc.hpp>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
|
@ -86,7 +88,9 @@ class CBackground : public IWidget {
|
|||
size_t m_imageRevision = 0;
|
||||
|
||||
// Video playback
|
||||
#ifdef HYPRLOCK_HAS_VIDEO
|
||||
UP<CVideoBackend> m_videoBackend;
|
||||
CTexture m_videoTexture;
|
||||
std::vector<uint8_t> m_uploadBuffer;
|
||||
#endif
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue