Skip to content

Commit

Permalink
refactor(monorepo): Bring in reason-skia (round 2) (#880)
Browse files Browse the repository at this point in the history
* Build reason-skia and examples

* Hook up Skia tests

* Add SkiaSdl example

* Bring over benchmarks

* Fix doc generation

* Formatting

* Update lockfiles

* Fix warnings

* Install skia dll too
  • Loading branch information
bryphe committed Jun 3, 2020
1 parent 30ef409 commit 8e0479e
Show file tree
Hide file tree
Showing 59 changed files with 4,080 additions and 190 deletions.
4 changes: 4 additions & 0 deletions .ci/esy-build-steps.yml
Expand Up @@ -17,3 +17,7 @@ steps:
displayName: 'esy @examples x HarfbuzzCli'
- script: esy @examples x FontQuery -family=Arial
displayName: 'esy @examples x FontQuery -family=Arial'
- script: esy @examples x SkiaCli
displayName: '@esy @examples x SkiaCli'
- script: esy @examples x SkiaCli.bc
displayName: '@esy @examples x SkiaCli.bc'
Binary file added assets/uv.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 10 additions & 30 deletions bench.esy.lock/index.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bench.json
Expand Up @@ -4,7 +4,7 @@
"run": "esy '@bench' x ReveryBench"
},
"override": {
"build": ["dune build -p font-manager,harfbuzz,Revery,ReveryBench -j4"],
"build": ["dune build -p font-manager,harfbuzz,skia,Revery,ReveryBench -j4"],
"install": [
"esy-installer ReveryBench.install"
],
Expand Down
1 change: 1 addition & 0 deletions bench/exe/Bench.re
@@ -1 +1,2 @@
ReveryBench.BenchFramework.cli();
Skia_Bench.BenchFramework.cli();
2 changes: 1 addition & 1 deletion bench/exe/dune
@@ -1,7 +1,7 @@
(executable
(name bench)
(public_name ReveryBench)
(libraries ReveryBench.lib)
(libraries ReveryBench.lib Skia_Bench)
(package ReveryBench)
)

Expand Down
3 changes: 3 additions & 0 deletions bench/reason-skia/BenchFramework.re
@@ -0,0 +1,3 @@
include Reperf.Make({
let config = Reperf.Config.create(~snapshotDir="bench/__snapshots__", ());
});
28 changes: 28 additions & 0 deletions bench/reason-skia/CanvasBench.re
@@ -0,0 +1,28 @@
open BenchFramework;

open Skia;

let options = Reperf.Options.create(~iterations=100000, ());

module Data = {
let makeSurface = (width, height) => {
let imageInfo = ImageInfo.make(width, height, Rgba8888, Premul, None);
Surface.makeRaster(imageInfo, 0, None);
};

let surface = makeSurface(800l, 600l);
let canvas = Surface.getCanvas(surface);
let paint = Paint.make();
};

let drawRectLtwh = () => {
Skia.Canvas.drawRectLtwh(Data.canvas, 1.0, 2.0, 100., 200., Data.paint);
};

bench(
~name="Canvas: drawRectLtwh",
~options,
~setup=() => (),
~f=drawRectLtwh,
(),
);
44 changes: 44 additions & 0 deletions bench/reason-skia/ColorBench.re
@@ -0,0 +1,44 @@
open BenchFramework;

let options = Reperf.Options.create(~iterations=100000, ());

module Data = {
let initialColor = Skia.Color.makeArgb(0xFFl, 0xFFl, 0xFFl, 0xFFl);
};

let makeArgb = () => {
let _: Skia.Color.t = Skia.Color.makeArgb(0xFFl, 0xFFl, 0xFFl, 0xFFl);
();
};

let makeArgbFloat = () => {
let _: Skia.Color.t = Skia.Color.Float.makeArgb(0.1, 0.2, 0.3, 0.4);
();
};

let getA = () => {
let _: int32 = Skia.Color.getA(Data.initialColor);
();
};

let getAFloat = () => {
let _: float = Skia.Color.Float.getA(Data.initialColor);
();
};

bench(
~name="Color: makeArgb (float)",
~options,
~setup=() => (),
~f=makeArgbFloat,
(),
);
bench(
~name="Color: getA (float)",
~options,
~setup=() => (),
~f=getAFloat,
(),
);
bench(~name="Color: makeArgb", ~options, ~setup=() => (), ~f=makeArgb, ());
bench(~name="Color: getA", ~options, ~setup=() => (), ~f=makeArgb, ());
77 changes: 77 additions & 0 deletions bench/reason-skia/MatrixBench.re
@@ -0,0 +1,77 @@
open BenchFramework;

let options = Reperf.Options.create(~iterations=100000, ());

module Data = {
let initialMatrix = Skia.Matrix.make();

let scale = {
let mat = Skia.Matrix.make();
Skia.Matrix.setScale(mat, 1.0, 2.0, 3.0, 4.0);
mat;
};

let translate = {
let mat = Skia.Matrix.make();
Skia.Matrix.setTranslate(mat, 1.0, 2.0);
mat;
};

let out = Skia.Matrix.make();

let rect = Skia.Rect.makeLtrb(1., 1., 100., 200.);
let outRect = Skia.Rect.makeLtrb(0., 0., 0., 0.);
};

let setScale = () => {
let () = Skia.Matrix.setScale(Data.initialMatrix, 1.0, 2.0, 1.0, 1.0);
();
};

let setTranslate = () => {
let () = Skia.Matrix.setTranslate(Data.initialMatrix, 1.0, 2.0);
();
};

let concat = () => {
let () = Skia.Matrix.concat(Data.out, Data.scale, Data.translate);
();
};

let preConcat = () => {
let () = Skia.Matrix.preConcat(Data.out, Data.scale);
();
};

let postConcat = () => {
let () = Skia.Matrix.postConcat(Data.out, Data.translate);
();
};

let mapRect = () => {
let () = Skia.Matrix.mapRect(Data.scale, Data.rect, Data.outRect);
();
};

bench(~name="Matrix: mapRect", ~options, ~setup=() => (), ~f=mapRect, ());

bench(~name="Matrix: preConcat", ~options, ~setup=() => (), ~f=preConcat, ());

bench(
~name="Matrix: postConcat",
~options,
~setup=() => (),
~f=postConcat,
(),
);

bench(~name="Matrix: concat", ~options, ~setup=() => (), ~f=concat, ());

bench(
~name="Matrix: setTranslate",
~options,
~setup=() => (),
~f=setTranslate,
(),
);
bench(~name="Matrix: setScale", ~options, ~setup=() => (), ~f=setScale, ());
29 changes: 29 additions & 0 deletions bench/reason-skia/RectBench.re
@@ -0,0 +1,29 @@
open BenchFramework;

let options = Reperf.Options.create(~iterations=100000, ());

module Data = {
let initialRect = Skia.Rect.makeLtrb(0., 0., 0., 0.);
};

let setLtrb = () => {
let () =
Skia.Rect.Mutable.setLtrb(~out=Data.initialRect, 1.0, 2.0, 3.0, 4.0);
();
};

let makeLtrb = () => {
let _: Skia.Rect.t = Skia.Rect.makeLtrb(1.0, 2.0, 3.0, 4.0);
();
};

let getLeft = () => {
let _: float = Skia.Rect.getLeft(Data.initialRect);
();
};

bench(~name="Rect: makeLtrb", ~options, ~setup=() => (), ~f=makeLtrb, ());

bench(~name="Rect: setLtrb", ~options, ~setup=() => (), ~f=setLtrb, ());

bench(~name="Rect: getLeft", ~options, ~setup=() => (), ~f=getLeft, ());
24 changes: 24 additions & 0 deletions bench/reason-skia/SkiaPaintBench.re
@@ -0,0 +1,24 @@
open BenchFramework;

open Skia;

let options = Reperf.Options.create(~iterations=100000, ());

module Data = {
let initialPaint = Paint.make();
let initialColor = Color.makeArgb(0xFFl, 0xFFl, 0xFFl, 0xFFl);
};

let make = () => {
let _: Paint.t = Paint.make();
();
};

let setColor = () => {
let () = Paint.setColor(Data.initialPaint, Data.initialColor);
();
};

bench(~name="Paint: make", ~options, ~setup=() => (), ~f=make, ());

bench(~name="Paint: setColor", ~options, ~setup=() => (), ~f=setColor, ());
9 changes: 9 additions & 0 deletions bench/reason-skia/dune
@@ -0,0 +1,9 @@
(library
(name Skia_Bench)
(ocamlopt_flags -linkall)
(libraries
skia
skia.wrapped
skia.wrapped.bindings
reperf.lib
))
40 changes: 10 additions & 30 deletions doc.esy.lock/index.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion doc.json
Expand Up @@ -5,7 +5,7 @@
"print": "esy '@doc' echo #{self.target_dir}/default/_doc/_html"
},
"override": {
"build": ["dune build @doc -p font-manager,harfbuzz,Revery -j4"],
"build": ["dune build @doc -p font-manager,harfbuzz,skia,Revery -j4"],
"dependencies": {
"@opam/odoc": "*",
"http-server": "*"
Expand Down
3 changes: 3 additions & 0 deletions dune-workspace
@@ -0,0 +1,3 @@
(lang dune 2.0)
(context (default
(disable_dynamically_linked_foreign_archives true)))

0 comments on commit 8e0479e

Please sign in to comment.