You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Summary
Adds a new CMake option `BABYLON_NATIVE_DISABLE_IMAGE_LOADING` (default
`OFF`) that strips all bimg / bx / stb / WebP image-decoding code from
the `NativeEngine` plugin. Useful for embedders that decode textures
themselves and want to reduce binary size.
## What it does when `ON`
- `bimg`, `bimg_encode`, `bimg_decode` are no longer linked into
`NativeEngine`.
- `BABYLON_NATIVE_PLUGIN_NATIVEENGINE_WEBP` is forced `OFF` (libwebp is
not fetched/built).
- All `<bimg/...>`, `<bx/...>`, `<stb/...>`, `<webp/...>` includes are
guarded out.
- All bimg-using helpers (`Cast`, `TransformImage`, `GetPixelMapper`,
`ReorientImage`, `ParseImage`, `PrepareImage`, `LoadTextureFromImage`,
`LoadCubeTextureFromImages`, related `static_assert`s) are excluded from
compilation.
- The following `NativeEngine` instance methods stay registered but
throw a `Napi::Error` (`"Image loading is disabled in this build
(BABYLON_NATIVE_DISABLE_IMAGE_LOADING)."`) when invoked:
- `loadTexture`
- `loadRawTexture`
- `loadRawTexture2DArray`
- `loadCubeTexture`
- `loadCubeTextureWithMips`
- `createImageBitmap`
- `resizeImageBitmap`
- `ReadTexture`'s bimg-based format-conversion path also throws; raw
readback when source/target formats match continues to work.
- `FlipImage` is kept available because it's also used by `ReadTexture`.
## Binary size impact
Measured on Windows x64 Release `Playground.exe` (MSVC, default
options):
| Build | `Playground.exe` |
|---|---|
| Image loading `ON` (default) | 3,610,112 bytes |
| Image loading `OFF` | 3,152,384 bytes |
| **Saved** | **457,728 bytes (~447 KiB, ~12.7%)** |
## How to use
```
cmake -B buildNoImage -A x64 -DBABYLON_NATIVE_DISABLE_IMAGE_LOADING=ON
cmake --build buildNoImage --target Playground --config Release
```
## Validation
- `cmake -B buildImage -DBABYLON_NATIVE_DISABLE_IMAGE_LOADING=OFF`
configure Γ£ö
- `cmake -B buildNoImage -DBABYLON_NATIVE_DISABLE_IMAGE_LOADING=ON`
configure Γ£ö (libwebp not fetched)
- Playground Release build Γ£ö for both
- Default behavior unchanged (option defaults to `OFF`).
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
0 commit comments