# MetaCrate Skia adapter

This crate implements the pinned `SkiaTextureCodec` behavior at a bounded,
project-owned image boundary. The core `libremetaverse-imaging` crate never
exposes a `skia-safe` type and never discovers or links Skia.

## Features and formats

The default feature set has no Skia dependency. `SkiaTextureCodec::decode`
returns a typed `InvalidOperation` error in that configuration, while conversion
from the checked project-owned `backend::SKBitmap` remains available for tests
and callers that already own decoded pixels.

Enable native decoding with:

```sh
cargo test -p libremetaverse-imaging-skia --features skia
```

The `skia` feature decodes the CPU codec formats supported by the pinned
rust-skia release: BMP, GIF, ICO, JPEG, PNG, WBMP, and WebP. Input is buffered
to at most 64 MiB. Dimensions are rejected before native pixel allocation when
they exceed the core 16,777,216-pixel limit, and decoded storage uses checked
strides and owned Rust buffers.

The mapped C# adapter exposes decoding and `SKBitmap`-to-`ManagedImage`
conversion only; it has no encoding or resize method. Encoding selection stays
with the format-specific imaging APIs, and callers use `ManagedImage`'s checked
resize methods after decoding. Premultiplied pixels are converted to straight
alpha at this boundary. RGB565, BGRA8888, RGBA8888, RGBA/BGRA1010102, Gray8,
Alpha8, row padding, and the reference byte-width fallback retain the pinned
C# channel and rounding rules.

## Binary cache and source builds

`skia-safe` 0.99.0 downloads an official prebuilt Skia archive when the target
and Cargo feature set match a published archive. MetaCrate deliberately selects
the published WebP-capable feature sets:

- Linux and Windows: JPEG, PDF, SVG, text layout, Vulkan, and WebP;
- macOS: JPEG, PDF, SVG, text layout, and WebP.

Vulkan is selected on Linux and Windows only to match the published CPU/WebP
archive; this adapter does not create a GPU context or call a platform graphics
API. The same feature is therefore usable on macOS, Linux, and Windows without
leaking platform-specific behavior.

Build prerequisites for the supported desktop targets are:

- Linux: a C++ linker/runtime, `curl`, `pkg-config`, FreeType, and Fontconfig;
- macOS: Xcode command-line tools and `curl`;
- Windows MSVC: the Rust MSVC toolchain, Visual Studio C++ build tools, and
  `curl`.

The build script downloads cache archives from the `rust-skia/skia-binaries`
GitHub releases. Pin or mirror `SKIA_BINARIES_URL` in offline/reproducible build
environments. `FORCE_SKIA_BINARIES_DOWNLOAD=1` makes a missing archive fail
instead of compiling Skia. If no archive matches and that variable is absent,
rust-skia falls back to a source build, which additionally requires Python 3,
Ninja, and an LLVM/Clang toolchain. `FORCE_SKIA_BUILD=1` selects that path
explicitly.

## Licensing and redistribution

`skia-safe` and rust-skia's bindings are MIT licensed; the linked Skia library
is BSD-3-Clause licensed. Official binary-cache archives contain compiled Skia.
Products that redistribute the resulting native artifacts must preserve the
applicable MIT and BSD notices and audit the exact archive they ship.
