Skip to content
Port of the Skia drawing library to wasm, for use in javascript (node & browser)
C++ C Other
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs hide scrollbars Jun 12, 2018
fonts/liberation-fonts
include
.gitattributes
.gitignore
LICENSE
README.md
build_bindings.sh
build_skia_wasm_bitcode.sh
example_gradient.js
example_star.js
example_text.js don't use emscripten wasm fake/virtual file system to load fonts Jan 5, 2018
libskia.a update skia headers Jun 6, 2018
out_gradient.png
out_star.png
out_text.png
skia.h
skia_bindings.cpp
wasm_compatible_build.patch

README.md

This project has been superseded by Google's CanvasKit

skia-wasm-port

Port of the Skia drawing library to wasm, for use in node & browser.

Skia is the drawing library used by Chrome and Firefox to provide the actual rendering of web pages.

Goal

The goal of this project is to make skia available to Javascript without the need to rely on native code. The end result would be a library able to do fast complex 2d drawings in both node & the browser.

State

Currently a limited set of skia functions are defined (wip), so the library is not very usable yet. You do get a static archive that contains all llvm bitcode needed to generate the final wasm, as well as a script to generate this llvm bitcode from Skia sources. This library will become usable as soon as enough bindings are defined.

An example is currently available under example_star.js that can be run with node. Running in the browser is also possible if the png file saving is adjusted accordingly. The example exactly matches the one found on the Skia website.

example_star.js demonstrates path rendering:

alt text

example_gradient.js demonstrates gradient shader:

alt text

example_text.js demonstrates font rendering:

alt text

WebGL

Skia WASM can also run in the browser while utilizing a WebGL accelerated back-end. This however requires some modifications to the existing Skia code, which is expected to be implemented upstream in the future. The provided Skia bitcode in this repository includes the needed WebGL changes. More information can be found here

A WebGL port of the Skia SDL example can be found in docs/webgl.js. You can try it out here. If the page fails to load, try disabling any adblocker.

Defining bindings

Bindings are defined using Embind. Currently defined bindings live in skia_bindings.cpp.

Building Bindings

This library requires git lfs

Make sure you have the emscripten sdk installed. Current code has been tested on the linux-incoming-64bit version.

Make sure you define the correct paths in build_bindings.sh and run build_bindings.sh. You should get a skia.js and a skia.wasm file. To test the build, simply run example_star.js.

Building Skia bitcode

Clone the official Skia git repository and copy over the build_skia_wasm_bitcode.sh script together with the wasm_compatible_build.patch, then simply execute bash build_skia_wasm_bitcode.sh. Make sure you define the correct paths in the build script!

You can’t perform that action at this time.