feat(images): WebP decode via libwebp + more stb formats
Broaden avatar/image support: - Add libwebp (FetchContent, static, decode-only) so WebP loads. Built from source for Linux / mingw-Windows / macOS-osxcross identically — the cross sysroots have no webp, so vendoring from source is the one portable path; encode/tool builds are disabled to avoid pulling in libpng/zlib. Linked as webp + webpdemux (the latter for animated WebP, wired next). - texture_loader routes all decode through DecodeImageRGBA: sniffs the RIFF/ WEBP header and uses libwebp (WebPDecodeRGBAInto into a free()-able buffer), else stb — so every existing caller (avatars, QR, thumbnails) gains WebP for free with no allocator mismatch. - Enable stb's TGA / PSD / PNM / PIC decoders and add .webp/.tga/.psd/.pnm/ .ppm/.pgm/.pic to the image-picker + avatar-library extension lists. Verified: libwebp builds static and a real .webp decodes to correct RGBA. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -295,6 +295,29 @@ else()
|
||||
set(CURL_INCLUDE_DIRS ${CURL_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
# libwebp - WebP decode (still + animated via WebPAnimDecoder). Built from source, static, decode-only
|
||||
# so Linux / mingw-Windows / macOS-osxcross all build it identically (the mingw/osx sysroots have no
|
||||
# webp). Encode tools are disabled to avoid pulling in libpng/zlib that the cross sysroots lack.
|
||||
message(STATUS "Fetching libwebp (decode-only, static)...")
|
||||
FetchContent_Declare(
|
||||
libwebp
|
||||
GIT_REPOSITORY https://github.com/webmproject/libwebp.git
|
||||
GIT_TAG v1.4.0
|
||||
GIT_SHALLOW TRUE
|
||||
)
|
||||
set(WEBP_LINK_STATIC ON CACHE BOOL "" FORCE)
|
||||
set(WEBP_BUILD_ANIM_UTILS OFF CACHE BOOL "" FORCE)
|
||||
set(WEBP_BUILD_CWEBP OFF CACHE BOOL "" FORCE)
|
||||
set(WEBP_BUILD_DWEBP OFF CACHE BOOL "" FORCE)
|
||||
set(WEBP_BUILD_GIF2WEBP OFF CACHE BOOL "" FORCE)
|
||||
set(WEBP_BUILD_IMG2WEBP OFF CACHE BOOL "" FORCE)
|
||||
set(WEBP_BUILD_VWEBP OFF CACHE BOOL "" FORCE)
|
||||
set(WEBP_BUILD_WEBPINFO OFF CACHE BOOL "" FORCE)
|
||||
set(WEBP_BUILD_LIBWEBPMUX OFF CACHE BOOL "" FORCE)
|
||||
set(WEBP_BUILD_WEBPMUX OFF CACHE BOOL "" FORCE)
|
||||
set(WEBP_BUILD_EXTRAS OFF CACHE BOOL "" FORCE)
|
||||
FetchContent_MakeAvailable(libwebp)
|
||||
|
||||
# libsodium - platform-specific
|
||||
# Search order per platform:
|
||||
# 1. Local pre-built in libs/libsodium{-mac,-win}/ (downloaded by scripts/fetch-libsodium.sh)
|
||||
@@ -735,6 +758,7 @@ target_include_directories(ObsidianDragon PRIVATE
|
||||
${GLAD_INCLUDE}
|
||||
${CURL_INCLUDE_DIRS}
|
||||
${MINIZ_DIR}
|
||||
${libwebp_SOURCE_DIR}/src # <webp/decode.h>, <webp/demux.h> (FetchContent build tree)
|
||||
)
|
||||
|
||||
target_link_libraries(ObsidianDragon PRIVATE
|
||||
@@ -744,6 +768,8 @@ target_link_libraries(ObsidianDragon PRIVATE
|
||||
sqlite3_amalgamation
|
||||
${CURL_LIBRARIES}
|
||||
${SODIUM_LIBRARY}
|
||||
webp
|
||||
webpdemux # WebPAnimDecoder (animated WebP); transitively pulls in webp + sharpyuv
|
||||
)
|
||||
|
||||
if(DRAGONX_LITE_BACKEND_READY)
|
||||
|
||||
Reference in New Issue
Block a user