Skip to content

Commit

Permalink
fix: DOMMatrix to skia Transform
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn committed Feb 11, 2023
1 parent c82d41d commit fd9afdc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
10 changes: 0 additions & 10 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,14 @@ rustflags = ["-C", "link-args=/NODEFAULTLIB:libcmt.lib"]
rustflags = ["-C", "target-cpu=apple-a14"]

[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
rustflags = ["-C", "target-cpu=cortex-a57"]

[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"
rustflags = ["-C", "target-cpu=cortex-a7"]

[target.x86_64-unknown-linux-musl]
rustflags = [
"-C",
"target-feature=-crt-static",
]

[target.aarch64-unknown-linux-musl]
linker = "aarch64-linux-musl-gcc"
rustflags = [
"-C",
"target-feature=-crt-static",
"-C",
"target-cpu=cortex-a57",
]
19 changes: 16 additions & 3 deletions src/ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1868,7 +1868,7 @@ impl CanvasRenderingContext2D {
Either::A(a) => Transform::new(
a as f32, c? as f32, e? as f32, b? as f32, d? as f32, f? as f32,
),
Either::B(transform) => transform.into(),
Either::B(transform) => transform.into_context_transform(),
};
self
.context
Expand Down Expand Up @@ -1915,14 +1915,27 @@ pub struct TransformObject {
pub f: f64,
}

impl TransformObject {
pub(crate) fn into_context_transform(self) -> Transform {
Transform::new(
self.a as f32,
self.c as f32,
self.e as f32,
self.b as f32,
self.d as f32,
self.f as f32,
)
}
}

impl From<TransformObject> for Transform {
fn from(value: TransformObject) -> Self {
Self::new(
value.a as f32,
value.c as f32,
value.e as f32,
value.b as f32,
value.c as f32,
value.d as f32,
value.e as f32,
value.f as f32,
)
}
Expand Down

1 comment on commit fd9afdc

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: fd9afdc Previous: c82d41d Ratio
Draw house#skia-canvas 25 ops/sec (±0.41%) 24 ops/sec (±0.05%) 0.96
Draw house#node-canvas 23 ops/sec (±1.29%) 26 ops/sec (±0.66%) 1.13
Draw house#@napi-rs/skia 22.6 ops/sec (±0.4%) 23 ops/sec (±0.29%) 1.02
Draw gradient#skia-canvas 24.1 ops/sec (±1%) 22.9 ops/sec (±0.03%) 0.95
Draw gradient#node-canvas 22 ops/sec (±0.22%) 25.3 ops/sec (±0.27%) 1.15
Draw gradient#@napi-rs/skia 21.8 ops/sec (±0.37%) 22.5 ops/sec (±0.15%) 1.03

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.