diff --git a/CMakeLists.txt b/CMakeLists.txt index 67c6c9f..c96c7b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,6 +74,19 @@ else() add_compile_definitions(JXL_FOUND) endif() +pkg_check_modules( + HEIF + IMPORTED_TARGET + libheif +) + +if(NOT HEIF_FOUND) + file(GLOB_RECURSE HEIFFILES CONFIGURE_DEPENDS "src/*Avif.cpp") + list(REMOVE_ITEM SRCFILES ${HEIFFILES}) +else() + add_compile_definitions(HEIF_FOUND) +endif() + add_library(hyprgraphics SHARED ${SRCFILES}) target_include_directories( hyprgraphics @@ -86,6 +99,10 @@ if(JXL_FOUND) target_link_libraries(hyprgraphics PkgConfig::JXL) endif() +if(HEIF_FOUND) + target_link_libraries(hyprgraphics PkgConfig::HEIF) +endif() + # tests add_custom_target(tests) diff --git a/src/image/Image.cpp b/src/image/Image.cpp index 43600fb..98c9ac2 100644 --- a/src/image/Image.cpp +++ b/src/image/Image.cpp @@ -4,6 +4,9 @@ #ifdef JXL_FOUND #include "formats/JpegXL.hpp" #endif +#ifdef HEIF_FOUND +#include "formats/Avif.hpp" +#endif #include "formats/Webp.hpp" #include "formats/Png.hpp" #include diff --git a/src/image/formats/Avif.hpp b/src/image/formats/Avif.hpp new file mode 100644 index 0000000..0caab56 --- /dev/null +++ b/src/image/formats/Avif.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include +#include +#include +#include +#include + +namespace AVIF { + std::expected createSurfaceFromAvif(const std::string&); + std::expected createSurfaceFromAvif(const std::span&); +};