Skip to content

add webp#3097

Draft
mercury233 wants to merge 2 commits into
Fluorohydride:masterfrom
mercury233:patch-webp
Draft

add webp#3097
mercury233 wants to merge 2 commits into
Fluorohydride:masterfrom
mercury233:patch-webp

Conversation

@mercury233

Copy link
Copy Markdown
Collaborator

Support WebP-format card images.

TODO:

  • Discuss the practical value, since WebP loading is more than 4× slower than JPEG.
  • Add WebP support to Irrlicht, so background images and other assets can also use WebP.
  • Add options such as prefer_webp to avoid repeatedly attempting nonexistent paths when loading WebP-format card images.
  • Improve the build system.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds optional WebP card image support by integrating libwebp (vendored on Windows, system on Linux/macOS), introducing a WebP decode helper in ImageUtility, and updating the card image loader to fall back to .webp files when no .jpg is found. The PR is explicitly marked WIP with several TODOs (performance trade-off discussion, prefer_webp option, build system polish, Irrlicht integration).

Changes:

  • New ImageUtility::LoadWebPImage mirroring the existing JPEG loader, with decode-time scaling and fast-path options for downscaled output.
  • ImageManager::GetImage now selects a loader function based on which of four candidate files exists (expansions/pics/*.jpg|webp, then pics/*.jpg|webp).
  • Build plumbing added for libwebp: premake options/include/link dirs, vendored premake project under premake/webp/, .gitignore, and CI workflow updates for Windows/Linux/macOS.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
premake5.lua Adds BUILD_WEBP, options, include dir, and conditional include "webp".
premake/webp/src/webp/config.h Empty config used only when SIMD detection is disabled.
premake/webp/premake5.lua Vendored libwebp static-lib project with SIMD source selection.
gframe/premake5.lua Adds WebP include/lib dirs and links webp.
gframe/image_utility.h Declares LoadWebPImage.
gframe/image_utility.cpp Implements WebP decoder with decode-time scaling and fast-path tweaks.
gframe/image_manager.cpp Picks JPEG/WebP loader per file extension, with 4-step fallback chain.
.gitignore Ignores vendored /webp directory.
.github/workflows/build.yml Downloads/extracts libwebp on Windows, installs system libwebp on Linux, switches macOS to brew reinstall and adds webp, passes --build-webp.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@purerosefallen

Copy link
Copy Markdown
Collaborator

suggest to do after #3099

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants