tiny-skia 0.1.0

A stripped down Skia fork that supports only 2D shapes rendering on a CPU.
Documentation

tiny-skia

Build Status Crates.io Documentation

tiny-skia is a stripped down Skia fork that supports only 2D shapes rendering on a CPU and provides a Rust API. Designed specifically for resvg.

Despite being a fork, it's still compatible with a mainline Skia. There are no additive modifications. So you can build it using embedded Skia or you can provide your own build.

Embedded Skia version: 85

Removed

  • GPU support
  • Text rendering
  • Non-desktop OS'es support
  • Image codec
  • pathops
  • Structure flattening (SkFlattenable)
  • All external dependencies

The full diff can be found at tiny.patch

This reduces the source code size from 370 KLOC down to 80 KLOC. Compilation time from 75s down to 18s on AMD 3700X. And, binary overhead from 3.3MiB down to 0.7MiB on Linux (used config).

Also, the official source tree is 4.3 GiB (with dependencies).

Build with embedded Skia

It's recommended to build Skia using clang, therefore we support only clang too. Cargo will automatically choose clang, but you can override it using CC and CXX environment variables.

Also, the embedded version doesn't rely on gn, cmake and/or ninja. Just cargo.

32-bit version is not supported.

Build:

cargo build --release

No external compile time and/or runtime dependencies required.

Windows specific

Only MSVC toolchain is supported.

Dependencies:

  • MSVS >= 2017
  • clang
  • Rust's stable-x86_64-pc-windows-msvc target

Build:

Open x64 Native Tools Command Prompt for VS 2017 and then:

set PATH="C:\Program Files\LLVM\bin";%PATH%
rustup default stable-x86_64-pc-windows-msvc
cargo build --release

Build with external Skia

You can bypass embedded Skia compilation and jump strait to linking.

To do so, you have to set two environment variables:

  1. SKIA_DIR should point to a Skia directory that contains the include directory.
  2. SKIA_LIB_DIR should point to a Skia directory that contains skia.dll.

And then do the same steps as with embedded Skia.

The external Skia version should be the same as embedded one. Other versions are not supported right now, but pull requests are welcome.

Prior work

skia-c was originally written by JaFenix for resvg's Skia backend. And was based on Qt bindings for resvg.

License

The same as used by Skia: New BSD License

This licence covers all directories except skia. This one has its own licence.